Re: I'm always a winner



"TOF" <fran_beta@xxxxxxxxxxx> writes:

Evan Kirshenbaum wrote:
"TOF" <fran_beta@xxxxxxxxxxx> writes:

It's *deemed* a number for mathematical purposes (an integer),
although it lacks one of the key attributes of a number -- the
capacity to be a divisor. Divide by zero in any equation and you get
a non-return In JScript you get "isNAN" as the result: i.e. "is not
a number".

Not quite. First off, the value is "NaN"[1]. isNAN is the
predicate you use to tell that that's what you have. (One of the
properties of NaN is that it isn't equal to anything, including
itself, so you can't just check it against a NaN you happen to have
laying around.)


Quite right. I don't know why I typed that. There's a similar
isNumeric in VB too.

Second, that's only the value if you divide zero by zero. If you
divide a non-zero value by zero, you get positive or negative
infinity, depending on whether the numerator is positive or
negative and whether the denominator is 0 or -0.

True, but then infinity (positive or negative) isn't a number either,
or perhaps an *undefined* one.

In this system (IEEE floating point), it actually is a number (just as
NaN) is. It's got a value, and the results of operations on it are
well-defined. It's just not one of your garden-variety "real
numbers".

You also get NaN when you subtract add two infinite values with
opposite signs or subtract an infinite value from another with the
same sign, when you multiply an infinite value by zero or when you
divide one infinite value by another. Or when you perform any
arithmetic operation when one of the arguments is a NaN.

Yes ...

Finally, I have to take issue with your claim. Zero is a perfectly
good divisor in these systems. The result is NaN.

Well if it doesn't return a number, it's not as good as one that
does. A purely notional or undefined return is qualitatively less
useful than one that does return something definable.

Again, it's not an undefined return. It's a number within the
system. The elements of the system being "floating-point values" with
finite precision, they're not acually real numbers, anyway.

[1] actually one of many[2] NaNs, half of which are "quiet NaNs" and
the other half of which are "signalling NaNs". This one is a
quiet one.

Tell me more. That is interesting.

How much more do you want to know? An IEEE floating point number has
three parts, a sign bit (S), an exponent (E), and a fraction (F). The
exponent is a power of two and is biased (not two's complement) to
allow both positive and negative exponents. The fraction carries an
implicit 1 bit at the beginning. Zero is represented as E and F both
zero, but the sign bit allows you to distinguish between positive and
negative zero.

When E has the maximum value, if F is zero, you have positive or
negative infinity. If F has any other value, it's a NaN. If the
high-order bit of F is set, it's a signalling NaN, otherwise it's a
quiet NaN. The other bits of F can theoretically be used to identify
the situation that led to the NaN. The difference is intended to be
that you use signalling NaNs to trap conditions that need attention.
(For example, uninitialized memory may be preloaded with signalling
NaNs.) Normal arithmetic operations produce and propagate quiet NaNs.

--
Evan Kirshenbaum +------------------------------------
HP Laboratories |The body was wrapped in duct tape,
1501 Page Mill Road, 1U, MS 1141 |weighted down with concrete blocks
Palo Alto, CA 94304 |and a telephone cord was tied
|around the neck. Police suspect
kirshenbaum@xxxxxxxxxx |foul play...
(650)857-7572

http://www.kirshenbaum.net/


.



Relevant Pages

  • Re: Forth PARANOIA
    ... A domain error may occur if x is zero and y ... If the second argument is NaN, ... and the second argument is negative infinity, ... argument is less than zero but not a finite odd integer, ...
    (comp.lang.forth)
  • Re: Numerics, NaNs, IEEE 754 and C99
    ... only aceptable return value for a division by zero. ... Inf was a much better choice. ... returned Inf for divide by zero (which is the behavior required ... Why was this convention chosen instead of NaN, ...
    (comp.lang.python)
  • Re: Newbie to Forums, SIMD question
    ... Both of these converse most rapidly when x is near zero. ... mov ebx,ecx ... So far we've ignored zeros, denormals, infinities and NaNs. ... infinity or NaN, nor will it work for a negative x. ...
    (comp.lang.asm.x86)
  • Re: reading what you write
    ... I use a '*' format. ... The reader takes the err branch to 998. ... Normally zero was written out as 0.000000000. ... Some output was 'NaN'. ...
    (comp.lang.fortran)
  • Re: Im always a winner
    ... If black is not a color then zero is not a number. ... Divide by zero in any equation and you get ... NaN is that it isn't equal to anything, including itself, so you can't ... opposite signs or subtract an infinite value from another with the ...
    (alt.usage.english)

Loading