Why does “np.inf // 2” result in NaN and not infinity?

I’m going to be the person who just points at the C level implementation without any attempt to explain intent or justification:

*mod = fmod(vx, wx);
div = (vx - *mod) / wx;

It looks like in order to calculate divmod for floats (which is called when you just do floor division) it first calculates the modulus and float('inf') %2 only makes sense to be NaN, so when it calculates vx - mod it ends up with NaN so everything propagates nan the rest of the way.

So in short, since the implementation of floor division uses modulus in the calculation and that is NaN, the result for floor division also ends up NaN

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)