Merge pull request #328 from dcurrie/negative-zero

Fix roundtrip -0.0
This commit is contained in:
Yuichi Nishiwaki 2016-01-25 04:49:49 +09:00
commit 2607ec15c3
2 changed files with 8 additions and 6 deletions

View File

@ -426,12 +426,8 @@ void emyg_dtoa (double value, char* buffer) {
strcpy(buffer, signbit(value) ? "-inf.0" : "+inf.0");
else if (isnan(value))
strcpy(buffer, signbit(value) ? "-nan.0" : "+nan.0");
else if (value == 0) {
buffer[0] = '0';
buffer[1] = '.';
buffer[2] = '0';
buffer[3] = '\0';
}
else if (value == 0)
strcpy(buffer, signbit(value) ? "-0.0" : "0.0");
else {
if (value < 0) {
*buffer++ = '-';

View File

@ -17,6 +17,12 @@
(test #t (rountrip-ok +inf.0))
(test #t (rountrip-ok +0.0))
(test #t (rountrip-ok -0.0))
(test #t (rountrip-ok 0.0))
(test -inf.0 (string->number "-inf.0"))
(test +inf.0 (string->number "+inf.0"))