dtos fix
This commit is contained in:
@@ -93,16 +93,10 @@ PIString PIString::lltos(const llong num) {pisprintf("%lld", num);}
|
||||
PIString PIString::uitos(const uint num) {pisprintf("%u", num);}
|
||||
PIString PIString::ultos(const ulong num) {pisprintf("%lu", num);}
|
||||
PIString PIString::ulltos(const ullong num) {pisprintf("%llu", num);}
|
||||
PIString PIString::ftos(const float num, char format, int precision) {
|
||||
char f[8] = "%.";
|
||||
int wr = snprintf(&(f[2]), 8, "%d", precision);
|
||||
f[2 + wr] = format;
|
||||
f[3 + wr] = 0;
|
||||
pisprintf(f, num);
|
||||
}
|
||||
PIString PIString::dtos(const double num, char format, int precision) {
|
||||
char f[8] = "%.";
|
||||
int wr = snprintf(&(f[2]), 8, "%d", precision);
|
||||
int wr = snprintf(&(f[2]), 4, "%d", precision);
|
||||
if (wr > 4) wr = 4;
|
||||
f[2 + wr] = format;
|
||||
f[3 + wr] = 0;
|
||||
pisprintf(f, num);
|
||||
|
||||
@@ -1376,7 +1376,7 @@ public:
|
||||
//! piCout << PIString::fromNumber(123456789., 'g', 2); // 1.2e+08
|
||||
//! piCout << PIString::fromNumber(123456789., 'f', 0); // 123456789
|
||||
//! \endcode
|
||||
static PIString fromNumber(const float value, char format = 'f', int precision = 8) {return ftos(value, format, precision);}
|
||||
static PIString fromNumber(const float value, char format = 'f', int precision = 8) {return dtos(value, format, precision);}
|
||||
|
||||
//! \~english Returns string contains numeric representation of "value" with format "format" and precision "precision"
|
||||
//! \~russian Возвращает строковое представление числа "value" в формате "format" и точностью "precision"
|
||||
@@ -1454,7 +1454,6 @@ private:
|
||||
static PIString uitos(const uint num);
|
||||
static PIString ultos(const ulong num);
|
||||
static PIString ulltos(const ullong num);
|
||||
static PIString ftos(const float num, char format = 'f', int precision = 8);
|
||||
static PIString dtos(const double num, char format = 'f', int precision = 8);
|
||||
static PIString fromNumberBaseS(const llong value, int base = 10, bool * ok = 0);
|
||||
static PIString fromNumberBaseU(const ullong value, int base = 10, bool * ok = 0);
|
||||
|
||||
Reference in New Issue
Block a user