On 9 Sep 2005 03:14:44 -0700, "ve*********@hotmail.com"

<ve*********@hotmail.com> wrote:

>

>

>>double b = 0.0 / 0.0; // What is the value of b? NaN?

>

> See comment above.

> The result would be: Indetermined

>

No. Again, it's not an error. The result is NaN (not a number).

The result is indetermined not NaN seeing that it can be any number.

This is one of the few situations you do not get a NaN returned

(although a lot of material on the net assumes you get one) the other

situation I can come up with would trying to divide infinity by

infinity.

Actually, not if your compiler (and library) are IEEE-754 compliant. From the

standard:

7.1 Invalid Operation

The invalid operation exception is signaled if an operand is invalid for the

operation on to be performed. The result, when the exception occurs without a

trap, shall be a quiet NaN (6.2) provided the destination has a floating-point

format. The invalid operations are

1) Any operation on a signaling NaN (6.2)

2) Addition or subtraction—magnitude subtraction of infinites such as, (+inf)

+ (-inf)

3) Multiplication—0 * inf

4) Division—0/0 or inf/inf

5) Remainder— x REM y, where y is zero or x is infinite

6) Square root if the operand is less than zero

7) Conversion of a binary floating-point number to an integer or decimal

format when overflow, infinity, or NaN precludes a faithful representation in

that format and this cannot otherwise be signaled

8) Comparison by way of predicates involving < or >, without ?, when the

operands are unordered (5.7, Table 4)

Item 4 specifies that 0/0 results in a NaN if not otherwise trapped.

-dr