# # simple float test to calculate float unique numbers in range from -1..1 # # output: # # 1 -0.99999994 # 2 -0.9999999 # 3 -0.9999998 # 4 -0.99999976 # 5 -0.9999997 # 6 -0.99999964 # 7 -0.9999996 # 8 -0.9999995 # 9 -0.99999946 # 10 -0.9999994 # ... # 2130706425 0.9999996 # 2130706426 0.99999964 # 2130706427 0.9999997 # 2130706428 0.99999976 # 2130706429 0.9999998 # 2130706430 0.9999999 # 2130706431 0.99999994 # 2130706432 1.0 # import numpy as np i = 0 f = np.float32(-1.) while ( f < 1. ): f = np.nextafter(f, np.float32(2)) i += 1 print(i, f) type(f)