Fix roundtrip -0.0

This commit is contained in:
Doug Currie 2016-01-23 16:30:40 -05:00
parent 7019f81aaf
commit 87ae66d706
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"); strcpy(buffer, signbit(value) ? "-inf.0" : "+inf.0");
else if (isnan(value)) else if (isnan(value))
strcpy(buffer, signbit(value) ? "-nan.0" : "+nan.0"); strcpy(buffer, signbit(value) ? "-nan.0" : "+nan.0");
else if (value == 0) { else if (value == 0)
buffer[0] = '0'; strcpy(buffer, signbit(value) ? "-0.0" : "0.0");
buffer[1] = '.';
buffer[2] = '0';
buffer[3] = '\0';
}
else { else {
if (value < 0) { if (value < 0) {
*buffer++ = '-'; *buffer++ = '-';

View File

@ -17,6 +17,12 @@
(test #t (rountrip-ok +inf.0)) (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"))
(test +inf.0 (string->number "+inf.0")) (test +inf.0 (string->number "+inf.0"))