Re: Rounding to the nearest 5

Discussion in 'Python' started by D'Arcy J.M. Cain, Jan 30, 2009.

  1. On Thu, 29 Jan 2009 16:06:09 -0800
    "" <> wrote:
    > How can you make python round numbers to the nearest 5:
    >
    > Example:
    >
    > 3 => 0
    > 8 => 10
    > 23.2 => 20
    > 36 => 35
    > 51.5 => 50


    That appears to be rounding to nearest 10, not 5. Clarify your
    requirements first.

    --
    D'Arcy J.M. Cain <> | Democracy is three wolves
    http://www.druid.net/darcy/ | and a sheep voting on
    +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
     
    D'Arcy J.M. Cain, Jan 30, 2009
    #1
    1. Advertising

  2. On Fri, 30 Jan 2009 00:24:47 -0500, D'Arcy J.M. Cain wrote:

    > On Thu, 29 Jan 2009 16:06:09 -0800
    > "" <> wrote:
    >> How can you make python round numbers to the nearest 5:
    >>
    >> Example:
    >>
    >> 3 => 0
    >> 8 => 10
    >> 23.2 => 20
    >> 36 => 35
    >> 51.5 => 50

    >
    > That appears to be rounding to nearest 10, not 5. Clarify your
    > requirements first.


    Look again. 36 => 35.



    --
    Steven
     
    Steven D'Aprano, Jan 30, 2009
    #2
    1. Advertising

  3. On 30 Jan 2009 06:23:17 GMT
    Steven D'Aprano <> wrote:
    > On Fri, 30 Jan 2009 00:24:47 -0500, D'Arcy J.M. Cain wrote:
    > > That appears to be rounding to nearest 10, not 5. Clarify your
    > > requirements first.

    >
    > Look again. 36 => 35.


    You are correct. I should have ommitted my first sentence and
    emphasized the second. :)

    --
    D'Arcy J.M. Cain <> | Democracy is three wolves
    http://www.druid.net/darcy/ | and a sheep voting on
    +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
     
    D'Arcy J.M. Cain, Jan 30, 2009
    #3
    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. Greg Young [MVP]

    Re: rounding values to the nearest 5 or 10

    Greg Young [MVP], Apr 27, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    473
    Greg Young [MVP]
    Apr 27, 2006
  2. chaz
    Replies:
    0
    Views:
    388
  3. =?ISO-8859-1?Q?G=F6ran_Andersson?=

    Re: rounding values to the nearest 5 or 10

    =?ISO-8859-1?Q?G=F6ran_Andersson?=, Apr 28, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    8,236
    Milsnips
    Apr 28, 2006
  4. Shea Martin
    Replies:
    7
    Views:
    3,566
    P.J. Plauger
    Oct 30, 2003
  5. Derek Basch
    Replies:
    8
    Views:
    417
    Fredrik Lundh
    Feb 28, 2006
Loading...

Share This Page