+ 1

Python calculation results problems

Why does print(456/10**2) output 4.56 But print((456/10**2)*100) output 455.999999999994 Shouldn’t it be 456? Thank you :)

11th Apr 2022, 3:51 AM
Interesting
Interesting - avatar
2 Respuestas
+ 4
1. exponentiation calculated firstly, then division and multiplication 2. processor calculats floating point expressions inaccurately
11th Apr 2022, 4:03 AM
Operand
Operand - avatar
0
But why though? Is it a flaw in python or just an online compiler mistake?
11th Apr 2022, 1:57 PM
Interesting
Interesting - avatar