mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-15 07:14:46 +02:00
fixed GH #1128: Poco::NumberFormatter::format(float, precision) rounding changed
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include <locale>
|
||||
#endif
|
||||
|
||||
|
||||
// binary numbers are supported, thus 64 (bits) + 1 (string terminating zero)
|
||||
#define POCO_MAX_INT_STRING_LEN 65
|
||||
// value from strtod.cc (double_conversion::kMaxSignificantDecimalDigits)
|
||||
@@ -441,16 +442,25 @@ bool uIntToStr (T number, unsigned short base, std::string& result, bool prefix
|
||||
// http://florian.loitsch.com/publications/dtoa-pldi2010.pdf
|
||||
//
|
||||
|
||||
|
||||
Foundation_API void floatToStr(char* buffer,
|
||||
int bufferSize,
|
||||
float value,
|
||||
int lowDec = -std::numeric_limits<double>::digits10,
|
||||
int highDec = std::numeric_limits<double>::digits10);
|
||||
int lowDec = -std::numeric_limits<float>::digits10,
|
||||
int highDec = std::numeric_limits<float>::digits10);
|
||||
/// Converts a float value to string. Converted string must be shorter than bufferSize.
|
||||
/// Conversion is done by computing the shortest string of digits that correctly represents
|
||||
/// the input number. Depending on lowDec and highDec values, the function returns
|
||||
/// decimal or exponential representation.
|
||||
|
||||
Foundation_API void floatToFixedStr(char* buffer,
|
||||
int bufferSize,
|
||||
float value,
|
||||
int precision);
|
||||
/// Converts a float value to string. Converted string must be shorter than bufferSize.
|
||||
/// Computes a decimal representation with a fixed number of digits after the
|
||||
/// decimal point.
|
||||
|
||||
|
||||
Foundation_API std::string& floatToStr(std::string& str,
|
||||
float value,
|
||||
@@ -464,6 +474,17 @@ Foundation_API std::string& floatToStr(std::string& str,
|
||||
/// and width (total length of formatted string).
|
||||
|
||||
|
||||
Foundation_API std::string& floatToFixedStr(std::string& str,
|
||||
float value,
|
||||
int precision,
|
||||
int width = 0,
|
||||
char thSep = 0,
|
||||
char decSep = 0);
|
||||
/// Converts a float value, assigns it to the supplied string and returns the reference.
|
||||
/// This function calls floatToFixedStr(char*, int, float, int) and formats the result according to
|
||||
/// precision (total number of digits after the decimal point) and width (total length of formatted string).
|
||||
|
||||
|
||||
Foundation_API void doubleToStr(char* buffer,
|
||||
int bufferSize,
|
||||
double value,
|
||||
@@ -475,6 +496,15 @@ Foundation_API void doubleToStr(char* buffer,
|
||||
/// decimal or exponential representation.
|
||||
|
||||
|
||||
Foundation_API void doubleToFixedStr(char* buffer,
|
||||
int bufferSize,
|
||||
double value,
|
||||
int precision);
|
||||
/// Converts a double value to string. Converted string must be shorter than bufferSize.
|
||||
/// Computes a decimal representation with a fixed number of digits after the
|
||||
/// decimal point.
|
||||
|
||||
|
||||
Foundation_API std::string& doubleToStr(std::string& str,
|
||||
double value,
|
||||
int precision = -1,
|
||||
@@ -482,11 +512,22 @@ Foundation_API std::string& doubleToStr(std::string& str,
|
||||
char thSep = 0,
|
||||
char decSep = 0);
|
||||
/// Converts a double value, assigns it to the supplied string and returns the reference.
|
||||
/// This function calls doubleToStr(char*, int, float, int, int) and formats the result according to
|
||||
/// This function calls doubleToStr(char*, int, double, int, int) and formats the result according to
|
||||
/// precision (total number of digits after the decimal point, -1 means ignore precision argument)
|
||||
/// and width (total length of formatted string).
|
||||
|
||||
|
||||
Foundation_API std::string& doubleToFixedStr(std::string& str,
|
||||
double value,
|
||||
int precision = -1,
|
||||
int width = 0,
|
||||
char thSep = 0,
|
||||
char decSep = 0);
|
||||
/// Converts a double value, assigns it to the supplied string and returns the reference.
|
||||
/// This function calls doubleToFixedStr(char*, int, double, int) and formats the result according to
|
||||
/// precision (total number of digits after the decimal point) and width (total length of formatted string).
|
||||
|
||||
|
||||
Foundation_API float strToFloat(const char* str);
|
||||
/// Converts the string of characters into single-precision floating point number.
|
||||
/// Function uses double_convesrion::DoubleToStringConverter to do the conversion.
|
||||
@@ -513,10 +554,6 @@ Foundation_API bool strToDouble(const std::string& str, double& result, char dec
|
||||
///
|
||||
/// Returns true if succesful, false otherwise.
|
||||
|
||||
//
|
||||
// end double-conversion functions declarations
|
||||
//
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
Reference in New Issue
Block a user