Thread Links Date Links
Thread Prev Thread Next Thread Index Date Prev Date Next Date Index

Re: Conflicts between C standard and 754-2008



Michel,

I opine that rounding an overflow down to the largest representable
machine number and up to INF seems the only reasonable thing to do
for intervals.  Does the C99 standard specify directional
rounding for overflows in string conversion? If not, I still don't think it should influence what seems to be the only logical structure
in the interval context.

Best regards,

Baker

(being kept awake by "non-standard" fireworks)

On 12/31/2010 09:21 PM, Michel Hack wrote:
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



--

---------------------------------------------------------------
Ralph Baker Kearfott,   rbk@xxxxxxxxxxxxx   (337) 482-5346 (fax)
(337) 482-5270 (work)                     (337) 993-1827 (home)
URL: http://interval.louisiana.edu/kearfott.html
Department of Mathematics, University of Louisiana at Lafayette
(Room 217 Maxim D. Doucet Hall, 1403 Johnston Street)
Box 4-1010, Lafayette, LA 70504-1010, USA
---------------------------------------------------------------