Rounding curiosity

Discussion in 'Python' started by PyBo, Nov 17, 2004.

  1. PyBo

    PyBo Guest

    What is wrong with this picture:

    >>> x = 500000000.0
    >>> y = x / (1024 * 1024)
    >>> y

    476.837158203125
    >>> z = round(y, 2)
    >>> z

    476.83999999999997

    Obviously, '476.83999999999997' is not rounded to two
    decimal places. Or am I doing something wrong?
     
    PyBo, Nov 17, 2004
    #1
    1. Advertising

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. =?Utf-8?B?SmF5IEhpbHlhcmQ=?=

    ConfigurationManager and web.config and ASP.NET refresh curiosity

    =?Utf-8?B?SmF5IEhpbHlhcmQ=?=, Apr 5, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    908
    Brock Allen
    Apr 5, 2005
  2. =?Utf-8?B?cm9kY2hhcg==?=

    out of curiosity

    =?Utf-8?B?cm9kY2hhcg==?=, Sep 9, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    906
    =?Utf-8?B?cm9kY2hhcg==?=
    Sep 12, 2005
  3. Daisy
    Replies:
    3
    Views:
    4,079
    Steve Horsley
    Sep 12, 2005
  4. Richard
    Replies:
    2
    Views:
    380
    Jacqui or (maybe) Pete
    Jul 10, 2003
  5. PyBo

    Rounding curiosity

    PyBo, Nov 17, 2004, in forum: Python
    Replies:
    6
    Views:
    354
    Donn Cave
    Nov 17, 2004
Loading...

Share This Page