Re: rounding a number
- From: "arman" <previah@xxxxxxxxx>
- Date: 27 Nov 2006 22:38:51 -0800
Yes the y-axis is real (I gave a bad example). What I had in mind is
that I already decide how many steps y-axis has (for example 5; so
y-axis will reads: 0,2,4,6,8,10 (x10 multiplier/divider)). But it will
give unclear graphs if the maximum value of the graph 1.1 for example.
It would be better if the number steps is variable. So in this case, it
will make 6 steps (0,2,4,6,8,10,12 (x0.1)).
John Harper schreef:
In article <EPGah.112081$Fi1.29936@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
*** Hendrickson <***.hendrickson@xxxxxxx> wrote:
arman wrote:
Hi,You can fiddle around with the mod and modulus function. But, an
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.
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
I don't know whether Arman is really dealing with y-axis integers, or
with real variables that happen in his examples to have integer values.
If J and K above are real not integer then Arman won't get the benefit
of integer division above, and should replace K by NINT(K) or INT(K)
in experiments with ***'s two suggestions before deciding which of the
four possibilities to implement.
-- John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington 6140, New Zealand
e-mail john.harper@xxxxxxxxx phone (+64)(4)463 5341 fax (+64)(4)463 5045
.
- References:
- rounding a number
- From: arman
- Re: rounding a number
- From: *** Hendrickson
- Re: rounding a number
- From: John Harper
- rounding a number
- Prev by Date: Re: Fortran Error Problem
- Next by Date: Re: Fortran Error Problem
- Previous by thread: Re: rounding a number
- Next by thread: Re: rounding a number
- Index(es):