Programming Resources
For Fun and Learning
Charles Cusack
Computer Science
Hope College
main

Python
C++

JAVA


PHP
SQL
Alice

RoundoffError


Output.txt

Adding a small number to 1
1.000000000 + 0.000000050  = 1.000000000
1.000000000 + 0.000000060  = 1.000000119

Adding a small number to 1 a bunch of times
1.000000000 + 0.000000050*10000  = 1.000000000
1.000000000 + 0.000000060*10000  = 1.001192093

Adding a multiple of a small number to 1
1.000000000 + 0.000000050*10000  = 1.000499964
1.000000000 + 0.000000060*10000  = 1.000599980

(a-b)^2 == a*a - 2*a*b + b*b ?
(1.000000000 - 0.000000500)^2 = (0.999999523)^2  = 0.999999046
(1.000000000 - 0.000000500)^2  = 0.999998987
They are the not equal