$n1 = 0; $n2 = 0; for (1..1000) { # 0.1 is periodic in binary. # 0.1 requires an infinite number of bits to represent. $n1 += 0.1; # 0.5 = 2^(-1) # 0.5 requires one bit to represent. $n2 += 0.5; printf("%17.13f %17.13f\n", $n1, $n2); } #### ... 99.6999999999986 498.5000000000000 99.7999999999986 499.0000000000000 99.8999999999986 499.5000000000000 99.9999999999986 500.0000000000000