Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Rounding up nearest ten, hundred etc

by nite_man (Deacon)
on Sep 27, 2004 at 17:03 UTC ( #394252=note: print w/replies, xml ) Need Help??


in reply to Re: Rounding up nearest ten, hundred etc
in thread Rounding up nearest ten, hundred etc

But I am confused. In your example numbers of 1, 2 and 3 digits round to the nearest 10 and numbers of 4 digits round to the nearest 100. Could you please be more explicit about when to round to what?

It need to be rounded like that to find maximum number which will be used to build Y scale on the bar chart. That's way I need to round small numbers up to nearest ten, but big numbers - up to handred etc.

---
Michael Stepanov aka nite_man

It's only my opinion and it doesn't have pretensions of absoluteness!

  • Comment on Re^2: Rounding up nearest ten, hundred etc

Replies are listed 'Best First'.
Re^3: Rounding up nearest ten, hundred etc
by Zed_Lopez (Chaplain) on Sep 27, 2004 at 21:48 UTC

    What people are calling attention to is that your examples show us what you want for numbers 1-4 digits long, and the rule is different for numbers that are 1-3 digits long, and numbers that are 4 digits long. If we knew you were only ever interested in numbers 1-4 digits long, that'd be all we needed to know.

    But if you're potentially interested in longer numbers, we're left with no idea what behavior you want or expect for numbers longer than 4 digits.

    Basically, I don't know what to make of your 'etc.' above. Are numbers from 4-6 digits rounded to the next hundred, and then 7-9 digits rounded to the next thousand?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://394252]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2021-06-23 21:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (122 votes). Check out past polls.

    Notices?