Re: rounding a number
- From: Ron Shepard <ron-shepard@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 28 Nov 2006 00:07:58 -0600
In article <1164653909.212753.254800@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
"arman" <previah@xxxxxxxxx> 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.
You probably want something like
(((n-1)/10)+1)*10
or for a general integer blocksize BSIZE
(((n-1)/BSIZE)+1)*BSIZE
You should watch out for the border cases. For example, let n equal
99, 100, and 101 with BSIZE=10 and the above expression gives the
right result in all three cases. In your case, it is not clear if
you want BSIZE to be 10 or 100, but the general expression will work
in either case.
$.02 -Ron Shepard
.
- References:
- rounding a number
- From: arman
- rounding a number
- Prev by Date: 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):