why the accuracy of float is weakened in module

kou

Joined
Feb 27, 2012
Messages
1
Reaction score
0
Hi guys, thanks for coming in!!
I met a problem about the change of float's accuracy in module.
I simply put lines below in a .py file, and execute it in commend line.
def main():
i = 1.12345678901234567890
print i
if __name__ == "__main__":
main()

But the result is surprisingly 1.12345678901, instead of 1.1234567890123457. I'm quite surprised, since if I input
>>> i = 1.12345678901234567890
>>> print i
in commend line, the result would be 1.1234567890123457. I know the accuracy of float in python is 15.

So I'm totally lost, why does this happen?
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top