strtod.3: Fix return value for underflow
PATCH 1/1 strtod.3: Fix return value for underflow
In C89 strtod returns zero on underflow, but since C99 it can return non-zero. This means the strtod.3 page contradicts all recent C and POSIX standards. Both C and POSIX say "smallest normalized positive number", but for consistency with HUGE_VAL, HUGE_VALF and HUGE_VALL this patch uses the constants for those numbers.
Also slightly improve the presentation of return values for overflow.
man3/strtod.3 +14 -6
@@ -138,15 +138,23 @@ is stored in the location referenced by .IR endptr . .PP If the correct value would cause overflow, plus or minus -.B HUGE_VAL -.RB ( HUGE_VALF , -.BR HUGE_VALL ) -is returned (according to the sign of the value), and +.BR HUGE_VAL , +.BR HUGE_VALF , +or +.B HUGE_VALL +is returned (according to the return type and sign of the value), +and .B ERANGE is stored in .IR errno . -If the correct value would cause underflow, zero is -returned and +.PP +If the correct value would cause underflow, +a value with magnitude no larger than +.BR DBL_MIN , +.BR FLT_MIN , +or +.B LDBL_MIN +is returned and .B ERANGE is stored in .IR errno .
Hi again Jonathan,
Quoted 7 lines · Jonathan Wakely
In C89 strtod returns zero on underflow, but since C99 it can return non-zero. This means the strtod.3 page contradicts all recent C and POSIX standards. Both C and POSIX say "smallest normalized positive number", but for consistency with
HUGE_VAL,HUGE_VALFandHUGE_VALLthis patch uses the constants for those numbers.Also slightly improve the presentation of return values for overflow.
Thanks. I've also applied this patch.
Cheers,
Michael
Quoted 35 lines
man3/strtod.3 +14
-6@@ -138,15 +138,23 @@ is stored in the location referenced by .IR endptr . .PP If the correct value would cause overflow, plus or minus -.B HUGE_VAL -.RB ( HUGE_VALF , -.BR HUGE_VALL ) -is returned (according to the sign of the value), and +.BR HUGE_VAL , +.BR HUGE_VALF , +or +.B HUGE_VALL +is returned (according to the return type and sign of the value), +and .B ERANGE is stored in .IR errno . -If the correct value would cause underflow, zero is -returned and +.PP +If the correct value would cause underflow, +a value with magnitude no larger than +.BR DBL_MIN , +.BR FLT_MIN , +or +.B LDBL_MIN +is returned and .B ERANGE is stored in .IR errno .