octave-maintainers
[Top][All Lists]
Advanced

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

Re: sort error when NaN and NA are both present


From: Mark Messer
Subject: Re: sort error when NaN and NA are both present
Date: Tue, 17 Jan 2012 18:17:25 -0800

| > Every comparison with NaN is false. NA is just another name for NaN in
| > Octave. So NaN are unsorted. This is part of the IEEE 754 standard.
| > NA is a particular NaN value, so it would be possible to sort NA
| > vs. other NaN values. But I'm not sure it is worth the effort.
 
 
It looks like this is not a bug. Even though NaN and NA have different bit patterns, both are NaN values. Octave functions and operators treat NA just like NaN.
octave:772> num2hex(NaN)
ans = 7ff8000000000000
octave:773> num2hex(NA)
ans = 7ff840f440000000
octave:774> isnan(NA)
ans =  1
octave:775> isequalwithequalnans(NaN,NA)
ans =  1
octave:776> NaN==NaN
ans = 0
octave:777> NaN!=NaN
ans =  1
octave:778> NaN==NA
ans = 0
octave:779> NaN!=NA
ans =  1
octave:780> NA==NA
ans = 0
octave:781> NA!=NA
ans =  1
 
2012/1/17 John W. Eaton <address@hidden>
 
On 17-Jan-2012, Jordi Gutiérrez Hermoso wrote:
 
| On 17 January 2012 12:22, Mark Messer <address@hidden> wrote:
| > I am not sure if this is worth a bug report or not. These ought to have the
| > same answer.
| >
| > I am using 32 bit Windows Vista, and Octave 3.4.3.
| >
| >
| > octave:713> sort([NaN,NA,inf,1,-inf])
| > ans =
| >
| >   -Inf     1   Inf   NaN    NA
| >
| > octave:714> sort([NA,NaN,inf,1,-inf])
| >
| > ans =
| >
| >   -Inf     1   Inf    NA   NaN
|
| Every comparison with NaN is false. NA is just another name for NaN in
| Octave. So NaN are unsorted. This is part of the IEEE 754 standard.
 
 
NA is a particular NaN value, so it would be possible to sort NA
vs. other NaN values.  But I'm not sure it is worth the effort.
 
jwe
 
 
 

reply via email to

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