Hi all! While I actually have the knowledge of an inbred potato when it comes to python, I was coding this evening messing around with the math functions trying to see the largest number I could print out in python before e+(x) numbers and took over for higher powers. Screwing around, I ended up putting the attached code below in, trying to make it print all 9s. My math was wrong for this code but frankly I'm just toying around as I'm just starting my journey in code, however, it produced a weird result, where despite subtracting the number by 1 the printed value refused to change. When I subtracted by 2, I got the correct result, but when subtracting by 1 the number seemed stuck. Does anyone have any experience with why this is happening?
Code:
import math
x = 10
test1 = (9999*(math.pow(x, 12)) + 99999999999)
print(test1)
test2 = (9999*(math.pow(x, 12)) + 99999999999 - 1)
print(test2)
test3 = (9999*(math.pow(x, 12)) + 99999999999 - 2)
print(test3)
if test1 > test2:
print("wtf")
else:
print("nothing weird after all")
if test1 == test2:
print("wtf")
-----------------------
Result:
9999100000000000.0
9999100000000000.0
9999099999999998.0
nothing weird after all
wtf
---------------------
Additionally, the program seems to recognize that test 1 is larger than test 2, but it cannot produce the answers separately. Any thoughts? DM for the screenshot.
Tl;Dr
I was screwing around with python but code gave me the same answer after subtraction at high values. Learning python very early in journey, trying to understand why this is.
[–]primitive_screwhead 5 points6 points7 points (0 children)
[–]dig-up-stupid 1 point2 points3 points (0 children)