Why output is False? | SoloLearn: Learn to code for FREE!

+2

Why output is False?

a=9**19==(int(float(9**19))) print(int(a)) #output = 0 but why can anyone explain it.

8/18/2018 4:40:26 PM

Maninder $ingh

6 Answers

New Answer

+7

Apparently some digits are being truncated when you do int(float()) casting. Run in a Python shell to see the difference.

+4

You can't assign value to variable and compare it at once. What do you think what 'a' is? 9**19 or boolean

+2

I believe it has to do with the float function and how floats are handled in Python. https://docs.python.org/2/tutorial/floatingpoint.html

+2

try this a=9**19 print(int(a)) b=int((float(9**19))) print(b) You will see the difference

+1

a=int(9**19) print(a) #outputs 1350851717672992089 a=int(float(9**19)) print(a) #outputs 1350851717672992000 It seems that either "float" or "int" has some issues with python.

0

Just because of different estimations by compiler.