Conflicts between C standard and 754-2008
This is a follow-up on a thread started in stds-754. The relevance to
stds-1788 is that Interval Arithmetic depends on correct directed rounding.
The issue is that the C99 standard for string-to-floating-point conversion
(e.g. strtod(), atof() etc.) requires overflow (given value too large to
be representable in the target format) to return a single value, HUGE_VAL,
typically defined as Infinity on 754-based platforms. Yet 754 requires
two different overflow values, INF or MAX, depending on whether rounding
away from zero or towards zero, and this is a direct conflict.
Vincent Lefèvre suggested wrapping the C conversion in code that checks
errno for ERANGE (or checks the overflow flag when easily available and
consistently set), then fixes up the result based on the sign and rounding
direction, which is a pain. He also suggested opening a defect against
the standard...
The C99 standard does permit different values for underflow (provided
they don't exceed the smallest normal magnitude), but implementations
tend simply to return zero for all rounding directions, and Linux even
says so in its man page for strtod. The 754 standard requires either
zero or the smallest subnormal, depending on rounding direction. 1788
could live with returning either zero or the smallest normal -- as long
as containment is preserved.
What can we do about this?
Michel.
P.S. Happy New Year (to almost everybody, when you read this)
---Sent: 2011-01-01 03:37:09 UTC