Re: rounding a number
- From: Herman D. Knoble <SkipKnobleLESS@xxxxxxxxxxxxxxx>
- Date: Tue, 28 Nov 2006 08:22:47 -0500
Also see ACM (T.O.M.S.) ALGORITHM 463
by C R. Lewart whoch computes "nice" numeric endpoints and grid interval.
http://www.netlib.org/toms/index.html
Skip Knoble
On 28 Nov 2006 05:10:17 -0800, proximum@xxxxxxx wrote:
-|
-|"""arman ÐÉÓÁÌ(Á):
-|"""
-|> 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-
-|
-|Here is the part of my program that automatically fits axes and draws
-|the graph.
-|
-|xdiap=fmaxx-fminx !finding steps
-| ydiap=fmaxy-fminy
-|
-| stepx=10D0**(dnint(dlog10(xdiap)))
-|123 continue
-| if(xdiap.lt.stepx*3d0) stepx=stepx/4.d0
-| if(xdiap.lt.stepx*3d0) stepx=stepx/5.d0
-| if(xdiap.lt.stepx*3D0) then
-| stepx=stepx/5d0
-| goto 123
-| end if
-| end if
-|
-| stepy=1.d1**(dnint(dlog10(ydiap)))
-|124 continue
-| if(ydiap.lt.stepy*10D0) stepy=stepy/4.d0
-| if(ydiap.lt.stepy*10D0) stepy=stepy/5.d0
-| if(ydiap.lt.stepy*10D0) then
-| stepy=stepy/5.d0
-| goto 124
-| end if
-|62 if(ydiap.gt.stepy*1.5d1) then
-| stepy=stepy*2.d0
-| goto 62
-| end if
-|
-|129 continue
-|
-|!______________________________________________________
-| !finding axis location (location of first grid line)
-|
-| yaxisloc=stepx*dint(fminx/stepx)+2.d0*stepx
-| if(yaxisloc.gt.1.5d0*stepx+fminx)yaxisloc=yaxisloc-stepx
-| if(yaxisloc.lt.0.4d0*stepx+fminx)yaxisloc=yaxisloc+stepx
-|
-|
-| xaxisloc=stepy*dint(fminy/stepy)+2.d0*stepy
-| if(xaxisloc.gt.1.5d0*stepy+fminy)xaxisloc=xaxisloc-stepy
-| if(xaxisloc.lt.0.4d0*stepy+fminy)xaxisloc=xaxisloc+stepy
-|
-|!then add stepx or stepy and draw grid lines
.
- References:
- rounding a number
- From: arman
- Re: rounding a number
- From: proximum
- rounding a number
- Prev by Date: Re: rounding a number
- Next by Date: elemental function versus loop over function
- Previous by thread: Re: rounding a number
- Next by thread: Fortran Error Problem
- Index(es):
Relevant Pages
|