summaryrefslogtreecommitdiff
path: root/src/value.cc
diff options
context:
space:
mode:
authordon bright <hugh.m.bright@gmail.com>2013-02-16 02:36:32 (GMT)
committerdon bright <hugh.m.bright@gmail.com>2013-02-16 02:36:32 (GMT)
commit7ce648dacaf693012dad11c5bd8046bb681adaa7 (patch)
treeabd33902b025473035679b7fc35d96b98e18ca91 /src/value.cc
parentc7f855b130323964636ea34e1d0e8ddbeb91fb81 (diff)
better detection of '-0', make it into '0'
Diffstat (limited to 'src/value.cc')
-rw-r--r--src/value.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/value.cc b/src/value.cc
index 46b7e6f..5712e33 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -186,11 +186,10 @@ public:
if (op1 != op1) { // Fix for avoiding nan vs. -nan across platforms
return "nan";
}
- double tmpop = ( op1 == 0 ) ? 0 : op1; // Fix '-0' to '0'
std::stringstream tmp;
tmp.precision(12);
tmp.setf(std::ios_base::fixed);
- tmp << tmpop;
+ tmp << op1;
std::string tmpstr = tmp.str();
size_t endpos = tmpstr.find_last_not_of('0');
if (endpos >= 0 && tmpstr[endpos] == '.') endpos--;
@@ -200,6 +199,7 @@ public:
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
contact: Jan Huwald // Impressum