diff options
author | donbright <hugh.m.bright@gmail.com> | 2013-03-05 23:47:14 (GMT) |
---|---|---|
committer | donbright <hugh.m.bright@gmail.com> | 2013-03-05 23:47:14 (GMT) |
commit | 42f21c3a0850083d245aa3ac346a53e876f0679e (patch) | |
tree | facf41750e0fe27cc4cdaf352c9c8e687011d103 /src/value.cc | |
parent | 422c668dcb538f181683ae51305bf8d3404f48d6 (diff) | |
parent | 4734172c3a16cc06b09e4d2131aa8e380bd0f226 (diff) |
Merge pull request #288 from openscad/issue11_2
Issue11 2
Diffstat (limited to 'src/value.cc')
-rw-r--r-- | src/value.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/value.cc b/src/value.cc index 7744a18..5712e33 100644 --- a/src/value.cc +++ b/src/value.cc @@ -25,6 +25,7 @@ */ #include "value.h" +#include "printutils.h" #include <stdio.h> #include <math.h> #include <assert.h> @@ -196,15 +197,18 @@ public: size_t dotpos = tmpstr.find('.'); if (dotpos != std::string::npos) { if (tmpstr.size() - dotpos > 12) tmpstr.erase(dotpos + 12); + while (tmpstr[tmpstr.size()-1] == '0') tmpstr.erase(tmpstr.size()-1); } + if ( tmpstr.compare("-0") == 0 ) tmpstr = "0"; + tmpstr = two_digit_exp_format( tmpstr ); return tmpstr; #else - // attempt to emulate Qt's QString.sprintf("%g"); from old OpenSCAD. - // see https://github.com/openscad/openscad/issues/158 - std::stringstream tmp; - tmp.unsetf(std::ios::floatfield); - tmp << op1; - return tmp.str(); + // attempt to emulate Qt's QString.sprintf("%g"); from old OpenSCAD. + // see https://github.com/openscad/openscad/issues/158 + std::stringstream tmp; + tmp.unsetf(std::ios::floatfield); + tmp << op1; + return tmp.str(); #endif } |