Hi I made a script to calculate right triangles, and as a verification method, I used
if a != ((b*b)+(c*c))/a:
print("Incorrect")
However, for triangles bigger than 134217729, 9007199388958720, 9007199388958721 this method produced false negatives. When I changed the equation to
if a**2 != (b**2)+(c**2):
print("Incorrect")
it stopped producing false negatives. So what's the reason one of these work and the other doesn't? I used the following code to test:
b = 134217729
c = 9007199388958720
a = 9007199388958721
a = ((b*b)+(c*c))/a
print(a)
a = ((b**2)+(c**2))/a
print(a)
n = (b**2)+(c**2)
a = n**(1/2)
print(a)
a = 9007199388958721
if a**2 == (b**2)+(c**2):
print("Correct")
And the output was:
9007199388958720.0
9007199388958722.0
9007199388958722.0
Correct
What's going on???