* [patch] strtod.3: Fix return value for underflow
@ 2020-08-07 8:30 Jonathan Wakely
2020-08-23 18:04 ` Michael Kerrisk (man-pages)
0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Wakely @ 2020-08-07 8:30 UTC (permalink / raw)
To: mtk.manpages; +Cc: linux-man
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.
diff --git a/man3/strtod.3 b/man3/strtod.3
index a271498d5..56ddb5f27 100644
--- a/man3/strtod.3
+++ b/man3/strtod.3
@@ -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 .
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [patch] strtod.3: Fix return value for underflow
2020-08-07 8:30 [patch] strtod.3: Fix return value for underflow Jonathan Wakely
@ 2020-08-23 18:04 ` Michael Kerrisk (man-pages)
0 siblings, 0 replies; 2+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-08-23 18:04 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: linux-man
Hi again Jonathan,
On 8/7/20 10:30 AM, Jonathan Wakely wrote:
> 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.
Thanks. I've also applied this patch.
Cheers,
Michael
> diff --git a/man3/strtod.3 b/man3/strtod.3
> index a271498d5..56ddb5f27 100644
> --- a/man3/strtod.3
> +++ b/man3/strtod.3
> @@ -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 .
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-08-23 18:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-07 8:30 [patch] strtod.3: Fix return value for underflow Jonathan Wakely
2020-08-23 18:04 ` Michael Kerrisk (man-pages)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).