Fix roundtrip -0.0
This commit is contained in:
parent
7019f81aaf
commit
87ae66d706
|
@ -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++ = '-';
|
||||||
|
|
|
@ -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"))
|
||||||
|
|
Loading…
Reference in New Issue