Re: convertFormat and signaling NaN
We have just been discussing this exact issue in the working group devising C
binding for the revised standard. The C standard document (§6.3) is quite
clear that neither your examples (2) nor (3) can correspond to the
"Conversion of an operand value to a compatible type causes no change to the
value or the representation."
Signaling would require that a different NaN be returned per IEEE-754, §7.2:
"the default result of an operation that signals the invalid operation
exception shall be a quiet NaN"
In order to satisfy the requirements of the convertFormat operation as written
in IEEE-754, it might be necessary then to provide an explicit same-type
convertFormat function in C, separate from the explicit cast. However, the
actual remedy is under discussion. (In theory, at least, some other remedies
are also possible).
For that matter, we were also discussing whether this requirement of IEEE-754
(convertFormat including same-format conversions) was a deliberate choice or
the result of an oversight. At the time of our most recent discussion, none of
us could remember with certainty whether or not this was deliberate.
I don't presume to speak for the entirety of the C bindings working group, but
I believe that most of us would welcome any input from this list.
On Mar 13, 2011, at 4:22 PM, Vincent Lefevre wrote:
The convertFormat operation is under 5.4 (formatOf general-computational
operations), so that, according to 6.2, a signaling NaN shall signal the
invalid operation exception.
convertFormat doesn't preclude formatOf being the same format as source.
And the standard doesn't say that the behavior on signaling NaN should
So, what should the typical bindings be for casts and assignments in C,
assuming an implementation seeks to fully support the IEEE 754 standard?
double y, z;
/* ... */
z = (double) x; /* (1) */
z = (double) y; /* (2) */
z = y; /* (3) */
I'd say that the cast in (1) should obviously fall under convertFormat.
For consistency, the cast in (2) should also fall under convertFormat.
And I can't imagine that (2) and (3) would behave differently, as the
C standard regards assignments like casts, in the sense that they both
involve a conversion (ISO/IEC 9899:TC3: "In simple assignment (=), the
value of the right operand is converted to the type of the assignment
expression and replaces the value stored in the object designated by
the left operand."). Would this mean that a simple assignment between
variables of identical types would signal an exception on a signaling
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)