why the accuracy of float is weakened in module

Discussion in 'Python' started by kou, Feb 27, 2012.

  1. kou


    Feb 27, 2012
    Likes Received:
    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__":

    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: Feb 27, 2012
    kou, Feb 27, 2012
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.