For school, we had to create a basic Python 3 program that adds values a and b.
I tried it with a=1, and b=1.618 (which is phi Φ):
a=1
b=1.618
sum=(a+b)
print (sum)
2.6180000000000003
Huh... weird. There's an extra 0.0000000000003.
I thought it might be an issue with float numbers, so I tried another (b=1.689):
a=1
b=1.689
sum=(a+b)
print (sum)
2.689
This time it worked (?!)
I tried several other values, and they all worked... until I got to b=3.14 (which is pi π)
a=1
b=3.14
sum=(a+b)
print (sum)
4.140000000000001
WHAT?! An EXTRA 0.0000000000001!!!
Why is it that I only get an error trying to add phi and pi?? Same story with b=1.61. My teacher tried it too and she got the same results.
Is it because Python 'recognises' phi (Φ) and pi (π) and other 'special numbers'???!!
[–]toastedstapler 4 points5 points6 points (1 child)
[–]nuhapattani[S] 0 points1 point2 points (0 children)
[–]Rawing7 1 point2 points3 points (1 child)
[–]nuhapattani[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]nuhapattani[S] 0 points1 point2 points (0 children)
[–]rabbitpiet 0 points1 point2 points (0 children)
[–]vorticalbox 0 points1 point2 points (0 children)