diff options
author | Marius Kintel <marius@kintel.net> | 2012-08-02 02:02:23 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2012-08-02 02:02:23 (GMT) |
commit | 83879ab41c368f674ff771387f499dc36ce124dd (patch) | |
tree | 9a76c0f0f998a0abdbc2016d34bed5ff56b52540 | |
parent | 24fbfdf9551915918f43650057fea74b1ad76286 (diff) | |
parent | 8e4bc5d598cd59994731f3f8cadd980e9cdad6c7 (diff) |
Merge pull request #164 from openscad/issue158
Issue158
-rw-r--r-- | src/value.cc | 7 | ||||
-rw-r--r-- | testdata/scad/misc/echo-tests.scad | 4 | ||||
-rw-r--r-- | tests/regression/echotest/echo-tests-expected.txt | 1 |
3 files changed, 11 insertions, 1 deletions
diff --git a/src/value.cc b/src/value.cc index 666062a..3b7f357 100644 --- a/src/value.cc +++ b/src/value.cc @@ -198,7 +198,12 @@ public: } return tmpstr; #else - return boost::lexical_cast<std::string>(op1); + // 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 } diff --git a/testdata/scad/misc/echo-tests.scad b/testdata/scad/misc/echo-tests.scad index c42a67e..6753c61 100644 --- a/testdata/scad/misc/echo-tests.scad +++ b/testdata/scad/misc/echo-tests.scad @@ -12,3 +12,7 @@ echo(vec = [1,2,3]); echo(range = [0:2]); echo(str("string generated by str()")); + +// https://github.com/openscad/openscad/issues/158 rept by nop head +// 0.8 should print 0.8 not 0.80000...004 (regardless of internal representation) +echo(0.8); diff --git a/tests/regression/echotest/echo-tests-expected.txt b/tests/regression/echotest/echo-tests-expected.txt index ee9705f..d7ebe2f 100644 --- a/tests/regression/echotest/echo-tests-expected.txt +++ b/tests/regression/echotest/echo-tests-expected.txt @@ -7,3 +7,4 @@ ECHO: [1 : 2 : 10] ECHO: vec = [1, 2, 3] ECHO: range = [0 : 1 : 2] ECHO: "string generated by str()" +ECHO: 0.8 |