Print "1.000000" for a double 1 instead of "1", as in 6.10.

Uses the # modifier to printf using the "alternate form".
This commit is contained in:
Axel Naumann 2017-12-04 14:54:09 -06:00 committed by sftnight
parent fdca86db1d
commit 582af5e250

View File

@ -330,19 +330,19 @@ namespace cling {
// Reals // Reals
std::string printValue(const float *val) { std::string printValue(const float *val) {
cling::smallstream strm; cling::smallstream strm;
strm << llvm::format("%.5g", *val) << 'f'; strm << llvm::format("%#.5g", *val) << 'f';
return strm.str(); return strm.str();
} }
std::string printValue(const double *val) { std::string printValue(const double *val) {
cling::smallstream strm; cling::smallstream strm;
strm << llvm::format("%.6g", *val); strm << llvm::format("%#.6g", *val);
return strm.str(); return strm.str();
} }
std::string printValue(const long double *val) { std::string printValue(const long double *val) {
cling::smallstream strm; cling::smallstream strm;
strm << llvm::format("%.8Lg", *val) << 'L'; strm << llvm::format("%#.8Lg", *val) << 'L';
//strm << llvm::format("%Le", *val) << 'L'; //strm << llvm::format("%Le", *val) << 'L';
return strm.str(); return strm.str();
} }