Fix dtoa for +nan.0 +inf.0 -inf.0

This commit is contained in:
Doug Currie 2016-01-09 12:52:38 -05:00
parent edbd95d1bd
commit 30f220316c
1 changed files with 5 additions and 4 deletions

View File

@ -421,11 +421,12 @@ static inline void Prettify(char* buffer, int length, int k) {
}
void emyg_dtoa (double value, char* buffer) {
// Not handling NaN and inf
assert(!isnan(value));
assert(!isinf(value));
if (value == 0) {
if (isinf(value))
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';