why the accuracy of float is weakened in module

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

  1. kou

    kou

    Joined:
    Feb 27, 2012
    Messages:
    1
    Likes Received:
    0
    Location:
    CA
    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: Feb 27, 2012
    kou, Feb 27, 2012
    #1
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy
    Replies:
    7
    Views:
    6,668
    Roedy Green
    May 10, 2004
  2. dkultasev@gmail.com

    Hi, how to increase accuracy of float result ?

    dkultasev@gmail.com, May 5, 2005, in forum: C++
    Replies:
    15
    Views:
    835
    David Harmon
    May 5, 2005
  3. kk_oop@yahoo.com

    float accuracy: Corba IDL vs. C++

    kk_oop@yahoo.com, May 11, 2005, in forum: C++
    Replies:
    1
    Views:
    548
    Jonathan Mcdougall
    May 11, 2005
  4. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    1,448
    Mark Rae
    Dec 21, 2006
  5. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,914
    Smokey Grindel
    Dec 2, 2006
  6. DirtyHarry
    Replies:
    16
    Views:
    865
  7. Carsten Fuchs
    Replies:
    45
    Views:
    2,423
    James Kanze
    Oct 8, 2009
  8. benhoyt
    Replies:
    1
    Views:
    379
    Ross Ridge
    Feb 16, 2011
Loading...