Re: Rounding off double precision




In your case, use of the F90 Floor function thus:

double precision :: x
x= COS(90 * 3.141592653589793238d0 / 180.)
! round(x) = foor(x+0.5D0)
write(*,*) floor(x+0.5D0)
end

when compiled and run will write 0.0

For Fortran 77 define Floor as:
DINT(X)=X-DMOD(X,1.D0)
FLOOR(X)=DINT(X)-DMOD(2.D0+DSIGN(1.D0,X),3.D0)

For borderline cases of rounding to the nearest whole number one
can use a Fortran rendition of the APL toleranat (that is, fuzzy))
Floor (and Round functions:

http://ftp.aset.psu.edu/pub/ger/fortran/hdk/eps.f90
(this includes a sample main program).

Skip Knoble


On Fri, 28 Mar 2008 20:43:53 -0700 (PDT), Bamm <bammster@xxxxxxxxx> wrote:

-|I'm trying some calculations in double precision, and I'd like the
-|output rounded off so that errors in calculation are not shown. For
-|instance, the result of COS(90 * 3.141592653589793238d0 / 180.) is
-|-4.37113886E-06. I'd like it to be zero. Thanks for any help.

.



Relevant Pages

  • Re: Detailed ocenaic floor analysis. What does it really tell us?
    ... His numbers were too much perfect, so I made all the calculations myself ... and finally maps only showing black surface of oceanic crust ... I made maps showing the floor which age ranges from -180 MYA to ... the growth was really smooth. ...
    (sci.geo.geology)
  • Detailed ocenaic floor analysis. What does it really tell us?
    ... His numbers were too much perfect, so I made all the calculations myself ... dating from -180 MYA to X, X being the age limit of each isochrons. ... I made maps showing the floor which age ranges from -180 MYA to ... the growth was really smooth. ...
    (sci.geo.geology)
  • Re: laminate floor tips?
    ... If you are considering a light colored floor look at ... Aluminum oxide is the same stuff used ... You need to calculate it out before laying the first board. ... Use this to do your calculations. ...
    (alt.home.repair)
  • Re: HELP with Chroma Key!
    ... it took quite that much precision to get it to work well. ... Also, you mentioned "The excess length sweeps onto the floor, creating ... a perfect limbo cove for your keying". ... the excess fabric puddle onto the floor rather than cur it off when it ...
    (rec.video.production)
  • Re: how to reduce this numerical error
    ... Mike wrote: ... Dt = floor(Ct + eps(Ct)) ... next larger in magnitude floating point number of the same precision ...
    (comp.soft-sys.matlab)