Merge pull request #187 from divVerent/patch-1
authorDale Weiler <graphitemaster@users.noreply.github.com>
Mon, 4 Feb 2019 14:20:23 +0000 (09:20 -0500)
committerGitHub <noreply@github.com>
Mon, 4 Feb 2019 14:20:23 +0000 (09:20 -0500)
Fix printing of floating poing values in -dumpfin.

ir.cpp

diff --git a/ir.cpp b/ir.cpp
index facbc33fccaeaaf9829a4fcf72fd18a2e409f6d7..8388aab31df51492d1a40bbe665824f220a0c8fe 100644 (file)
--- a/ir.cpp
+++ b/ir.cpp
@@ -4054,10 +4054,11 @@ void ir_value::dump(int (*oprintf)(const char*, ...)) const
                 oprintf("fn:%s", m_name.c_str());
                 break;
             case TYPE_FLOAT:
-                oprintf("%g", m_constval.vfloat);
+                // %.9g is lossless for IEEE single precision.
+                oprintf("%.9g", m_constval.vfloat);
                 break;
             case TYPE_VECTOR:
-                oprintf("'%g %g %g'",
+                oprintf("'%.9g %.9g %.9g'",
                         m_constval.vvec.x,
                         m_constval.vvec.y,
                         m_constval.vvec.z);