NaN comparisons - Call For Anecdotes

Anders J. Munch 2014 at
Wed Jul 9 18:24:46 CEST 2014

Chris Angelico:
> If you need to do bitwise comparisons, then the easiest way is to use
> the bitpattern, converted to an integer. A 64-bit float becomes a
> 64-bit integer. It's then very simple to compare them, and reflexivity
> is maintained. At what point do you actually need them to be floats?
> What are you really doing with them?

What does one do with floats? Add, subtract, multipy, divide, display, input, 
store and retrieve to and from various formats.
All the usual stuff. Why would my use be different from anyone elses?

What you and Steven seem to be saying is that I should employ strategies to 
avoid NaNs ever being compared. I'll take that one step further and say that as 
long as NaN!=NaN, everyone should seek to avoid NaNs ever being compared.

regards, Anders

More information about the Python-list mailing list