Re: [PATCH] stdlib: Make strtod/strtof set ERANGE consistently for underflow.
Keith Packard <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
Joseph Myers <[email protected]> writes: >> This matches glibc behavior, as well as the Linux, Mac OS X, OpenBSD, >> FreeBSD and SunOS strtod man pages. (I should have said 'matches glibc in all of my tests, which are not exhaustive' :-) > What glibc does is set it when the IEEE underflow exception flag is > raised. That is, when the result is tiny and inexact, where "tiny" > follows each architecture's choice of before-rounding or after-rounding > tininess detection (neither of which means "the rounded result is > subnormal"; for both definitions of tiny results, there are values that > round to the least-magnitude normal value of their sign but are still > considered tiny, because after-rounding actually means "the result would > have a subnormal exponent if rounded to the same precision as for normal > values but with a wider exponent range"). Thanks for this clarification; I didn't realize that underflow had this additional subtly. It sounds like this means that there are additional cases where errno should be set to ERANGE in the code. I'm afraid I don't understand the workings of this function well enough to know how to detect this particular case. Could we somehow detect this using exceptions? Or are there places in the code which could add some direct checks? -- -keith
signature.asc
(application/pgp-signature, 832 B)
-----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEw4O3eCVWE9/bQJ2R2yIaaQAAABEFAmDSVVsACgkQ2yIaaQAA ABHKbQ//UcjgyMYtXvldukzHspzRBO0kwm4EBLVH9ews4CJSgXDygMNc8LUQps9m bvAaLXjy3jMhbziP1uKbGw1PCRBKZJwOwOhUacXoC12yfiNN4thUwySRKpYvNtTP 6QQl/40JJE8i1ozl5Poaf9on9I4kmnBYrgzypy7j5HUn/WMxlpxKE+/aXw2+EY0w Q5L4qvj/vKDQAcbcyHAftj68OXeEIUtNJO1CVtZmasRX3mdigsDCV5rnt5Ugrz6F YuYFBwDUIv9MRZEOXigU7bHRu2l3OPgpUJT8jHMzZ8LApJB7XwqrfxgnvQ2SQOkg 27JTbihGmpGVPGIEvDbMvdjRCGzICD5+BTwyXEk86ABpohQV5LlC7lAtcXaeoThY I2pP8fooHv3FiMsUrq54IHo9qLfwIrC+cxe3gRW7eJfY24ggxOhUxE6lCQI9iLiq HAsb/35jpX3n0bAcGQzDOhSVGT9GaJUVQvTFOk9hpSEYBcxjTHu9xSvneJ9csfIF rQOHCAeg9nV2DiogHkoR79zH4CjLudETFH4p9aPTZ4FChyZXVignbGL6oTvsOfz6 egxhkCLwO5w85rdedcNLus/7AgeM1tPKsejKFt0XGTezmGs+kq9iNFz90GD6RIiY EOneDiNqq/KigdBCpOTZlVVZJhUxmXf3Awi7pgicJ2lY275oC8c= =qv3K -----END PGP SIGNATURE-----