DEV Community

Discussion on: Printing floating point numbers with Gargi Sharma

Collapse
 
alephthoughts profile image
Abhishek Sharma • Edited

My favorite demo on importance of machine epsilon:

~
def f(x):
if x <= 1/2:
return 2 * x
if x > 1/2:
return 2*x - 1

x = 1/10
for i in range(80):
print(x)
x = f(x)
~