Re: Standard library praise and challenge
- Posted by jimcbrown (admin) Sep 14, 2011
- 3147 views
I understand the difference, but I'm still clueless on how to create positive NaN. Surely it's not as simple as multiplying by -1 ?
I think you can do stuff like sqrt(-1) (assuming you have exceptions or whatever turned off correctly).
I was looking for a quick series of mathematical functions that'd work as-in in 4.0 and 4.1 that would do the job, to prove a point.
(sqrt(-1) does not work in 4.0, btw).
The right way is to use whatever the language provides.
Agreed. Above all, I was trying to avoid this:
The headers define floats by explicit bytes for older versions of gcc.
Anyways, back to my original point: NaN and Nothing are conceptually separate values. NaN is a floating point number with a specific set of representations that are defined as the value of certain floating point operations (such as sqrt(-1) or fdiv(inf, inf)).
While it may make sense for NaN to be the output of std/math.e's min() and max() and sum() and perhaps even or_all() when they are given an empty sequence as input, NaN does not work the same way as our NOVALUE (or even Python's Nothing object).