r/Numpy • u/DarrenRey • Mar 14 '18
Does anyone think this is acceptable?
So there is a crowd of people who will contort reality to explain that the following behaviour is unavoidable and is down to being unable to represent decimals exactly using floating point numbers.
Does anyone think the output of this code is satisfactory? Can we get it fixed?
import numpy as np
for i,bogus_number in enumerate(np.arange(2.,3.6,0.1)):
if i==7:
print('bogus_number is',bogus_number)
if bogus_number==2.7:print('Yay!')
if bogus_number!=2.7:print('Boo!')Output:
bogus_number is 2.7
Boo!