diff options
author | Marius Kintel <marius@kintel.net> | 2013-03-06 18:08:31 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2013-03-06 18:08:31 (GMT) |
commit | cfc67f928fc86310614940f126d9f6c76d4e9ea7 (patch) | |
tree | 162be7579d3acd0eeb5b7b509ef9a0b428d6831f /src/value.cc | |
parent | fe44758f5096be0e98c82d2cb0d54bdeffc4403a (diff) | |
parent | 974abf13049d5e73227418e3990af8a9bbf9db09 (diff) |
Merge branch 'master' of github.com:openscad/openscad
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 } |