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

Conflicts between C standard and 754-2008



In the stds-754 thread Fred Tydeman came up with the right answer, by
quoting an up-to-date version of the C standard:

| The C standard says (7.22.1.3, paragraph 10):
|
|  The functions return the converted value, if any. If no conversion
|  could be performed, zero is returned. If the correct value overflows
-> and default rounding is in effect (7.12.1), plus or minus HUGE_VAL,
|  HUGE_VALF, or HUGE_VALL is returned (according to the return type and
|  sign of the value), and the value of the macro ERANGE is stored in
|  errno. If the result underflows (7.12.1), the functions return a value
|  whose magnitude is no greater than the smallest normalized positive
|  number in the return type; whether errno acquires the value ERANGE is
|  implementation-defined.
|
| So, strtod() can do what IEEE-754 requires.

Many strtod documentations "quote" the standard; I've that text above (or,
at any rate, extracts *almost* identical) many times, so on first reading
I did not notice the crucial tidbit about default rounding that I flagged
above.

So indeed, there is no conflict.  Unfortunately some IMPLEMENTATIONS of
the various conversion functions must have overlooked that tidbit too.

Michel.
---Sent: 2011-01-01 15:59:15 UTC