octave-maintainers
[Top][All Lists]
Advanced

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

Single Precision versus double precision NA


From: David Bateman
Subject: Single Precision versus double precision NA
Date: Fri, 30 May 2008 23:38:31 +0200
User-agent: Thunderbird 2.0.0.12 (X11/20080306)

I have a problem with the NA value for single precision. Ideally if I do

double vd = octave_NA;
float vf = static_cast<float>(vd);

I'd like vf to also be considered as have the value NA. However as the
distinguishing feature of the double NA is in the lower word, this is
lost when cast to a single precision value. If the double precision NaN
value that was considered as being NA was

0x7FF8 00F4 4000 0000

instead, when this was cast to a float it would become

0x7F8007A2

and both might be considered as being NA. Making this change would
however not be backward compatible particularly with NA values stored in
 files.

Without wrapping to float and double, I don't think we can overload the
assignment operators to check for NA values, so that leaves catching the
NA values in the FloatMatrix, etc constructors and in fact several
others places.

Alternatively, I can just not care about the issue and then casting a
double NA to a float NA or visa versa just won't work..

Any other ideas of how to handle this?

D.


reply via email to

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