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

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -