float(9**x) == 9**x = True , if x <= 16 but False if x> 16 why? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

float(9**x) == 9**x = True , if x <= 16 but False if x> 16 why?

converting int into float

18th Dec 2019, 5:05 PM
Ankur Singh Oli
Ankur Singh Oli - avatar
2 Answers
+ 4
That's because you're reaching maximum float precision. If you print the values when x=17, you'll understand what's happening. Nice catch!
18th Dec 2019, 6:15 PM
Gonçalo Magalhaes
Gonçalo Magalhaes - avatar
0
I used to think float just adds ".0" at the end of a int . But now I think it does something else. Can you please explain what it does actually?
18th Dec 2019, 6:40 PM
Ankur Singh Oli
Ankur Singh Oli - avatar