python - Negative infinity and negative zero in numpy -
this more of general understanding question
a = np.array([-0, 5, 0]).astype(float) b = 1 / print b returns [ inf 0.2 inf]
but
a = np.array([-0.0, 5, 0]) b = 1 / print b returns [-inf 0.2 inf]
i expected first 1 return -inf first element well, why doesn't it?
integers on machines have no concept of negative zero, -0 0. since build array integers before cast float, [0.0, 5, 0.0].
in [2]: np.array([-0, 5, 0]).astype(float) out[2]: array([ 0., 5., 0.])
Comments
Post a Comment