Hacker News new | ask | show | jobs
by recursive 2034 days ago
I'm not talking about math. I'm talking about computer numbers, specifically IEEE-754.

NaN is represented by a maximal (all ones) exponent, and at least one non-zero in the mantissa. Infinity has the same exponent but an all-zero mantissa. So with a naive comparison, NaN compares greater than infinity.

If you only believe output from programming languages, javascript claims that the type of infinity is "number".

    >>> typeof Number.POSITIVE_INFINITY
    "number"
1 comments

I know you were talking about floating point. That is why I said what I said using python code. It seems to be a concrete representation of IEEE-754 math. Also from my reading and understanding numpy is written by scientists that understand IEEE-754 perhaps a little more than some others.

I was fully away of that stuff you say about how NaN is represented and was also aware of how Inf is represented. My statement and link to the concept of Infinity on mathforum was an effort to support the idea of why most math done with code involving Inf will also result in an answer of Inf.

The article that this whole discussion is about seems to think it is OK (ie not a bug) to convert a float like Inf to a integer do some math and convert back to a float and get 1.5 and that is OK. It seems like a bug to me.