Merge pull request #164 from openscad/issue158

Issue158
felipesanches-svg
Marius Kintel 2012-08-01 19:02:23 -07:00
commit 83879ab41c
3 changed files with 11 additions and 1 deletions

View File

@ -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
}

View File

@ -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);

View File

@ -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