]> sourceware.org Git - newlib-cygwin.git/commit
stdlib: Make strtod/strtof set ERANGE consistently for underflow.
authorKeith Packard <keithp@keithp.com>
Tue, 22 Jun 2021 17:26:26 +0000 (10:26 -0700)
committerJeff Johnston <jjohnstn@redhat.com>
Wed, 7 Jul 2021 17:22:02 +0000 (13:22 -0400)
commitfb01286fab9b370c86323f84a46285cfbebfe4ff
tree5c76458915bc8388cddb9786011d34bd7b1f5f3e
parent1290301b893189b50569ac9b43a62afd65e0e064
stdlib: Make strtod/strtof set ERANGE consistently for underflow.

The C standard says that errno may acquire the value ERANGE if the
result from strtod underflows. According to IEEE 754, underflow occurs
whenever the value cannot be represented in normalized form.

Newlib is inconsistent in this, setting errno to ERANGE only if the
value underflows to zero, but not for denorm values, and never for hex
format floats.

This patch attempts to consistently set errno to ERANGE for all
'underflow' conditions, which is to say all values which are not
exactly zero and which cannot be represented in normalized form.

This matches glibc behavior, as well as the Linux, Mac OS X, OpenBSD,
FreeBSD and SunOS strtod man pages.

Signed-off-by: Keith Packard <keithp@keithp.com>
newlib/libc/stdlib/strtod.c
This page took 0.082302 seconds and 5 git commands to generate.