libc: Make sure that all constant floating point values have F suffix in strtof()

This commit is contained in:
Gregory Nutt 2016-10-20 13:03:15 -06:00
parent 2b22666554
commit e30a47ba46

View File

@ -75,7 +75,7 @@
static inline int is_real(float x) static inline int is_real(float x)
{ {
const float infinite = 1.0/0.0; const float infinite = 1.0F/0.0F;
return (x < infinite) && (x >= -infinite); return (x < infinite) && (x >= -infinite);
} }
@ -101,7 +101,7 @@ float strtof(FAR const char *str, FAR char **endptr)
int n; int n;
int num_digits; int num_digits;
int num_decimals; int num_decimals;
const float infinite = 1.0/0.0; const float infinite = 1.0F/0.0F;
/* Skip leading whitespace */ /* Skip leading whitespace */
@ -123,7 +123,7 @@ float strtof(FAR const char *str, FAR char **endptr)
break; break;
} }
number = 0.; number = 0.0F;
exponent = 0; exponent = 0;
num_digits = 0; num_digits = 0;
num_decimals = 0; num_decimals = 0;
@ -132,7 +132,7 @@ float strtof(FAR const char *str, FAR char **endptr)
while (isdigit(*p)) while (isdigit(*p))
{ {
number = number * 10. + (*p - '0'); number = number * 10.0F + (*p - '0');
p++; p++;
num_digits++; num_digits++;
} }
@ -145,7 +145,7 @@ float strtof(FAR const char *str, FAR char **endptr)
while (isdigit(*p)) while (isdigit(*p))
{ {
number = number * 10. + (*p - '0'); number = number * 10.0F + (*p - '0');
p++; p++;
num_digits++; num_digits++;
num_decimals++; num_decimals++;
@ -157,7 +157,7 @@ float strtof(FAR const char *str, FAR char **endptr)
if (num_digits == 0) if (num_digits == 0)
{ {
set_errno(ERANGE); set_errno(ERANGE);
number = 0.0; number = 0.0F;
goto errout; goto errout;
} }
@ -214,7 +214,7 @@ float strtof(FAR const char *str, FAR char **endptr)
/* Scale the result */ /* Scale the result */
p10 = 10.; p10 = 10.0F;
n = exponent; n = exponent;
if (n < 0) n = -n; if (n < 0) n = -n;
while (n) while (n)