Keep It Simple, Stupid PerlMonks

### Re: Best way to round a number.

 on Oct 25, 2012 at 00:06 UTC ( #1000738=note: print w/replies, xml ) Need Help??

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.

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.

Create A New User
Node Status?
node history
Node Type: note [id://1000738]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2018-04-22 09:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
My travels bear the most uncanny semblance to ...

Results (82 votes). Check out past polls.

Notices?