help-octave
[Top][All Lists]
Advanced

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

## Re: max() and min() of nan/inf

 From: Olli Saarela Subject: Re: max() and min() of nan/inf Date: Tue, 21 Sep 1999 09:00:32 +0300

```Hello,

> Is this a correct behaviour?
>
> max() or min() return nan is a nan is one of its arguments? max() or
> min() considering +/-Inf looks OK.

Yes, it is correct. Of course this is a matter of definition (defined in
the IEEE Standard 754), but the following example tries to give some
rationale:

John is 186 cm long.
Mark is 176 cm long.
I don't know how long Philip is (= NaN).
How long is the longest of them (= max)? Can't be answered (= NaN).

A NaN value (Not a Number) is not a real number. It doesn't have a
magnitude which could be compared. The min and max functions return the
smallest and the largest number of the set of numbers given. When the
set contains a NaN, the numbers don't any more have a minimum or a
maximum value. Hence, the value NaN is returned, indicating that there
is no number equal to the minimum or maximum value of the set.

> arithmetic or comparition operations
> are of course not defined on nans...

But they are defined. Any arithmethic operation with a NaN operand is
defined to evaluate to NaN. Any comparison with a NaN operand is defined
to evaluate to FALSE (except the ~= operation to TRUE).

For example:
Is NaN bigger than 3? No.   (NaN > 3) --> FALSE
Is NaN smaller than 3? No.  (NaN < 3) --> FALSE
Is NaN equal to 3? No.      (NaN == 3) --> FALSE

For more complete description, please see:
http://www.lpthe.jussieu.fr/DOC_HTML/WorkShop/common-tools/numerical_comp_guide/goldberg1.ps

Best regards,
Olli
--
Olli Saarela                       KCL Development Oy
address@hidden                tel. +358-9-4371538 (office)
Tekniikantie 2, Espoo-Otaniemi     fax. +358-9-464305
P.O. Box 70, FIN-02151 Espoo, Finland

---------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.  To ensure
that development continues, see www.che.wisc.edu/octave/giftform.html
Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
---------------------------------------------------------------------

```

reply via email to

 [Prev in Thread] Current Thread [Next in Thread]