NaN comparisons - Call For Anecdotes

Anders J. Munch 2014 at jmunch.dk
Wed Jul 9 17:08:15 CEST 2014


Steven D'Aprano wrote:
> It seems to me that the trivial work-around is:
>
> * gather packed floats from some device, as ints
> * process them *as ints* in some way which requires reflexivity
> * unpack back into floats
> * (maybe) much later perform numeric calculations on them
>
>
> Although perhaps I don't understand your use-case.

Clearly you do not. floats are not ints. I have no idea how you imagine 
processing IEEE-754 floating-point values in int form.

My use case is: Working with IEEE-754 floating-point values. That means storing 
and retrieving them, serialising and transferring them, accepting them as user 
input, printing them, all the usual things you do with values.

And doing so in a way that does not require special handling in algorithms that 
are otherwise generic.
When the same algorithm is capable of dealing with ints, bytestrings, text 
string, tuples, list, dictionaries, time stamps, NoneType's, bools, 
floating-point floats and a thousand other things, then NaNs stand out as the 
values that have special algorithm-breaking magic.

I gave an example of such an algorithm in an earlier reply to Chris.

regards, Anders




More information about the Python-list mailing list