http://www.perlmonks.org?node_id=1000738


in reply to Best way to round a number.

Why would 33 be rounded down to the nearest lower multiple of 5; and 36 be rounded up to the nearest higher multiple of 5? (Ditto: 33 down to 30; but 3 up to 5?)

Replies are listed 'Best First'.
Re^2: Best way to round a number.
by Anonymous Monk on Oct 25, 2012 at 00:37 UTC
    Alright, forget the multiple of 5 thing, its to the nearest 5 per say; therefore 33, should go to 30 because of the logic on the sample code I gave here, if the last number in this case is 3 (from 33), is less than five it should go to 30. So number 11 should go down to 10, 17 should round up to 20, I hope I am a lil clear on that now, thanks!
      I hope I am a lil clear on that now, thanks!

      Not really. Are you saying that

      1. if it is less that xx5, it rounds down.
      2. if it is greater than xx5 it rounds up.
      3. But if it is equal to xx5, it stays as is?

      If so, that is a very peculiar rounding mode?


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      RIP Neil Armstrong

      How is 33 closer to 30 than to 35?

      30 31 32 33 34 35

      I count two numbers between 30 and 33, but only one number between 33 and 35. Clearly 33 is closer to 35.