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

Popular posts from this blog

How to check data type in C++? -

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

sql server - SQL Query returns one result, does not return 0 or NULL result -