Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: [netbsd-7] src/lib/libc/stdlib



Module Name:    src
Committed By:   snj
Date:           Sun Dec 18 06:31:01 UTC 2016

Modified Files:
        src/lib/libc/stdlib [netbsd-7]: strtod.3 strtol.3 strtoul.3

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1311):
        lib/libc/stdlib/strtod.3: revisions 1.21-1.29
        lib/libc/stdlib/strtol.3: revision 1.36-1.38
        lib/libc/stdlib/strtoul.3: revision 1.36
strtod yields ERANGE for below-subnormal magnitudes, not underflow.
For a floating-point computation, in the language of IEEE 754,
`underflow' means the output was rounded and is too small to be
represented *normally*.
There are many nonzero floating-point numbers to which the exact
output may have been rounded -- namely subnormals.  The condition
under which strtod returns ERANGE for small magnitudes is when the
magnitude of the exact result is so small it is rounded to zero, not
even to a subnormal.
While here, use parallel language about large magnitudes instead of
the (albeit correct) word `overflow', to avoid temptation to treat
`underflow' as the opposite notion with zero instead of infinity.
--
Bump date for previous.
--
Fix description of ERANGE cases again.
Do use the technical terms `overflow' and `underflow', because strtod
sets ERANGE precisely to indicate either of these two conditions, and
they are the right keywords that one might be looking for.
Note that strtod may set ERANGE even if it returns noninfinity and
nonzero -- specifically, if the result is subnormal.  This part was
wrong before I `fixed' it and remained wrong after I `fixed' it
earlier this year.
--
Add example for strtod.
This illustrates all the cases you might be interested in and asserts
theorems in those cases.
--
Fix infinity detection with isinf(d), not d == HUGE_VAL.
Negative infinity counts as overflow too.
Simplify.
--
EXIT_FAILURE police
--
Distinguish altogether invalid syntax from trailing garbage.
--
Distinguish invalid syntax from trailing garbage cases.  Clarify.
--
Simplify error condition case.
Add assertions to reflect its implications.
--
Tidy up the second example too.
--
Update strtoul(3) example to reflect clarifications in strtol(3).
--
Fix phrasing about `out-of-band' and `sentinel value'.
Either an out-of-band channel, or an in-band sentinel value, could
indicate an error, but an out-of-band sentinel value is a silly
proposition.
Noted by uwe@.
--
Use the keywords `underflow' and `overflow' in ERANGE summary.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.20.50.1 src/lib/libc/stdlib/strtod.3
cvs rdiff -u -r1.26.24.2 -r1.26.24.3 src/lib/libc/stdlib/strtol.3
cvs rdiff -u -r1.25.24.2 -r1.25.24.3 src/lib/libc/stdlib/strtoul.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index