Use %g instead of %f, to preserve precision.

This commit is contained in:
Axel Naumann 2017-11-03 21:28:59 +01:00 committed by sftnight
parent c912c9437d
commit 3bf7bc1a48

View File

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