From 3bf7bc1a4845aa61aea870059740758a19dc3067 Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Fri, 3 Nov 2017 21:28:59 +0100 Subject: [PATCH] Use %g instead of %f, to preserve precision. --- lib/Interpreter/ValuePrinter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Interpreter/ValuePrinter.cpp b/lib/Interpreter/ValuePrinter.cpp index 7b243a00..b070fdc3 100644 --- a/lib/Interpreter/ValuePrinter.cpp +++ b/lib/Interpreter/ValuePrinter.cpp @@ -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(); }