octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #63713] Feature request: NaN should be able to


From: Rik
Subject: [Octave-bug-tracker] [bug #63713] Feature request: NaN should be able to take the same class input options as ones and zeros
Date: Sat, 28 Jan 2023 14:37:19 -0500 (EST)

Follow-up Comment #2, bug #63713 (project octave):

I also don't think this is a good idea.  NaN is a feature of floating point
number systems such as IEEE double or single.  It is not a part of integer
number representations or logical representations.  There is a subtle
difference between creating a value which the programmer believes represents
the underlying value/concept and cast() in which the programmer (even if only
implicitly) accepts that there may be information loss when converting from
one representation to another.  For example, "cast (1000, 'uint8')" returns
255.  The number 1,000 isn't representable in uint8 and some information was
lost.  Similarly, "cast (NaN, 'uint8')" loses information and returns 0.  As a
small aside, this would also introduce an incompatibility with Matlab.  I
tried this code, "NaN (5, 'uint8')" and Matlab throws an error.  Also, to be
consistent we would need to make all of the numeric functions which accept a
class (pi(), e(), I(), NaN(), Inf()).


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63713>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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