Re: rounding a number



arman wrote:
Hi,
How do you round some arbitrary number to the 10 multiplier? I need to
make a graph. The y-axis is dependent on the result of the computation.
If the maximum value of the y-axis, say for example 278, then I want
the y-axis to have a maximum of 300, or if it 2435 then I want the
maximum of 2500. So, basically it has to convert an arbitrary number
into some integer number that can be divided by 10.

thanks in advance,
-arman-

You can fiddle around with the mod and modulus function. But, an
easier way Is to just do an integer divide.
J = K/10*10 + 10
will do what you want/ The divide throws away the remainder, the
multiply brings you back to a multiple of 10 that is smaller than you
want and the + 10 rounds up.

If you want to be careful about rounding values that are a multiple of
10, you could experiment with
J = (K+9)/10*10

*** Hendrickson
.


Quantcast