1
0
Fork 0

Removed ftoa NaN check

NaN check may not work with optimizing compilers. Use your implementation specific NaN check if necessary
development
Marco Paland 8 years ago
parent c6c8d96420
commit 2b3f3c1306

@ -223,10 +223,11 @@ static size_t _ftoa(double value, char* buffer, size_t maxlen, unsigned int prec
// powers of 10 // powers of 10
static const double pow10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 }; static const double pow10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 };
// test for NaN // test for negative
if (!(value == value) && (maxlen > 2U)) { bool negative = false;
buffer[0] = 'n'; buffer[1] = 'a'; buffer[2] = 'n'; if (value < 0) {
return (size_t)3U; negative = true;
value = 0 - value;
} }
// limit precision // limit precision
@ -238,12 +239,6 @@ static size_t _ftoa(double value, char* buffer, size_t maxlen, unsigned int prec
prec = 9U; prec = 9U;
} }
unsigned int negative = 0U;
if (value < 0) {
negative = 1U;
value = 0 - value;
}
int whole = (int)value; int whole = (int)value;
double tmp = (value - whole) * pow10[prec]; double tmp = (value - whole) * pow10[prec];
unsigned long frac = (unsigned long)tmp; unsigned long frac = (unsigned long)tmp;

Loading…
Cancel
Save