Changeset 826 for cpp/frams/util
- Timestamp:
- 11/25/18 20:13:18 (6 years ago)
- Location:
- cpp/frams/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/util/sstring-simple.cpp
r793 r826 3 3 #include "extvalue.h" 4 4 #include <assert.h> 5 #ifdef USE_PRINTFLOAT_DRAGON4 6 #include <PrintFloat/PrintFloat.h> 7 #endif 5 8 6 9 void SString::initEmpty() … … 224 227 SString SString::valueOf(double d) 225 228 { 226 SString tmp = SString::sprintf("%.15g", d); 229 #ifdef USE_PRINTFLOAT_DRAGON4 230 SString tmp; 231 char* here = tmp.directWrite(30); 232 tmp.endWrite(PrintFloat64(here, 30, d, 233 ((d < -1e17) || (d > 1e17) || ((d < 1e-4) && (d > -1e-4) && (d != 0.0))) 234 ? PrintFloatFormat_Scientific : PrintFloatFormat_Positional, 235 -1));//http://www.ryanjuckett.com/programming/printing-floating-point-numbers/ 236 #else 237 SString tmp = SString::sprintf("%.17g", d); //https://stackoverflow.com/questions/16839658/printf-width-specifier-to-maintain-precision-of-floating-point-value 238 #endif 227 239 if ((!strchr(tmp.c_str(), '.')) && (!strchr(tmp.c_str(), 'e'))) tmp += ".0"; 228 240 return tmp; -
cpp/frams/util/sstring.cpp
r793 r826 23 23 #include "extvalue.h" 24 24 #include <assert.h> 25 #ifdef USE_PRINTFLOAT_DRAGON4 26 #include <PrintFloat/PrintFloat.h> 27 #endif 25 28 26 29 #ifdef MULTITHREADED … … 363 366 SString SString::valueOf(double d) 364 367 { 365 SString tmp = SString::sprintf("%.15g", d); 368 #ifdef USE_PRINTFLOAT_DRAGON4 369 SString tmp; 370 char* here=tmp.directWrite(30); 371 tmp.endWrite(PrintFloat64(here,30,d, 372 ((d<-1e17)||(d>1e17)||((d<1e-4)&&(d>-1e-4)&&(d!=0.0))) 373 ? PrintFloatFormat_Scientific : PrintFloatFormat_Positional, 374 -1));//http://www.ryanjuckett.com/programming/printing-floating-point-numbers/ 375 #else 376 SString tmp = SString::sprintf("%.17g", d); //https://stackoverflow.com/questions/16839658/printf-width-specifier-to-maintain-precision-of-floating-point-value 377 #endif 366 378 if ((!strchr(tmp.c_str(), '.')) && (!strchr(tmp.c_str(), 'e'))) tmp += ".0"; 367 379 return tmp;
Note: See TracChangeset
for help on using the changeset viewer.