linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: mtk.manpages@gmail.com
Cc: linux-man@vger.kernel.org
Subject: [patch] strtod.3: Fix return value for underflow
Date: Fri, 7 Aug 2020 09:30:57 +0100	[thread overview]
Message-ID: <20200807083057.GA2498597@redhat.com> (raw)

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 .


             reply	other threads:[~2020-08-07  8:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-07  8:30 Jonathan Wakely [this message]
2020-08-23 18:04 ` [patch] strtod.3: Fix return value for underflow Michael Kerrisk (man-pages)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200807083057.GA2498597@redhat.com \
    --to=jwakely@redhat.com \
    --cc=linux-man@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).