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
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…