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

Re: FW: Transcendental function tables: comments welcome!



On 2007-05-28 22:49:30 +1000, Peter Henderson wrote:
If one takes what is in the IEEE 754 and the drafts as a guide, in the 
first instance, NaN's are the return value appropriate for a domain error, 
e.g. 0.0/0.0, sqrt(-1.0) and a NaN input indicates such an error has 
occurred, and thus should be propagated.

The -1.0 in sqrt could have been obtained because of a rounding error,
and NaN means here that we don't know anything about the value. But
since for any x, x^0 is 1, it makes sense not to propagate the NaN.

Moreover infinities may also indicate a domain error and they are not
propagated (1/inf gives 0).

If such domain errors arise naturally in a calculation, they
indicate a special case that requires special attention.

It requires special attention as long as it is used. But when
considering a constant function, one may consider that special cases
no longer matter. You have a similar behavior with affectations, that
can replace a NaN by another value.

This is in accord with the general principle of the standard, where
one deals with the unexceptional case using a straight-forward
approach and then do a single check at the end to determine if
special measures are required.

Yes, and that's why a (global) flag is useful: it just needs a single
check, whereas testing values may require much more work (e.g. if the
result is a huge matrix).

For this reason, the above argument does not hold, i.e. pow(x,y)
always returns NaN if either argument is a NaN. The only exception
to this principle that I can see are the min/maxNum and
min/maxNumMag functions, which treat NaN as an uninitialised value
to be ignored. I had the impression this caused much angst and
argument in the committee a few years ago.

If you agree with the fact that NaN can represent an uninitialised
value, you should also agree with the fact that NaN can also represent
any valid number.

The idea the NaN represents any number is not really supported by the 
standard.  What happens if you attempt to ascii to binary conversion of 
"purple".

There are several points of view. For instance, "purple" represents
a number, but for some reason, it has not been replaced by its real
value, and regarding NaN as any number is consistent with this point
of view.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)

754 | revision | FAQ | references | list archive