summaryrefslogtreecommitdiff
path: root/src/value.cc
diff options
context:
space:
mode:
authorchrysn <chrysn@fsfe.org>2013-06-25 11:19:37 (GMT)
committerchrysn <chrysn@fsfe.org>2013-06-25 12:26:28 (GMT)
commit077332ff5cb8a41de2922a6f1be00597b30a02dd (patch)
tree973b89eb9680d04011d8ea1df6e305b0cf5d9a76 /src/value.cc
parenta4b5449d4e42556cc2c4799623aa069073e7f9ac (diff)
normalize -nan and -0 in all output modes
having a stable output is not only relevant in testing, and with the main binary being used for more tests, having those normalizations takes load off the preparing scripts tests/{dumptest,echotest}
Diffstat (limited to 'src/value.cc')
-rw-r--r--src/value.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/value.cc b/src/value.cc
index ebb825d..8320aff 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -182,12 +182,15 @@ public:
}
std::string operator()(const double &op1) const {
-#ifdef OPENSCAD_TESTING
- // Quick and dirty hack to work around floating point rounding differences
- // across platforms for testing purposes.
if (op1 != op1) { // Fix for avoiding nan vs. -nan across platforms
return "nan";
}
+ if (op1 == 0) {
+ return "0"; // Don't return -0 (exactly -0 and 0 equal 0)
+ }
+#ifdef OPENSCAD_TESTING
+ // Quick and dirty hack to work around floating point rounding differences
+ // across platforms for testing purposes.
std::stringstream tmp;
tmp.precision(12);
tmp.setf(std::ios_base::fixed);
contact: Jan Huwald // Impressum