Re: rounding a number
- From: proximum@xxxxxxx
- Date: 28 Nov 2006 05:10:17 -0800
"""arman писал(а):
"""
Hi,computation.
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
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
.
- Follow-Ups:
- Re: rounding a number
- From: Herman D . Knoble
- Re: rounding a number
- References:
- rounding a number
- From: arman
- rounding a number
- Prev by Date: Re: random numbers in fortran
- Next by Date: Re: rounding a number
- Previous by thread: Re: rounding a number
- Next by thread: Re: rounding a number
- Index(es):
Relevant Pages
|