[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

convertFormat and signaling NaN



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
be different.

So, what should the typical bindings be for casts and assignments in C,
assuming an implementation seeks to fully support the IEEE 754 standard?

For instance:

  float x;
  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
NaN?

-- 
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)


754 | revision | FAQ | references | list archive