Re: storing an integer in a double precision
- From: Ron Shepard <ron-shepard@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 06 May 2011 00:02:24 -0500
In article <ipv2j5$g2u$1@xxxxxxxxxxxxx>,
Lynn McGuire <lmc@xxxxxxxxxx> wrote:
Just a lack of understanding of conversion between integers and
double precision on my part. Back when we were primarily single
precision, we had to be very careful, using "ii = xx + 0.1" to
ensure that we did not loose the whole number value of a
incomplete conversion of 12,000 which was stored in the float
as 11.9999.
I have noticed lately that I have gotten lazy since we converted
the entire program to double precision and don't add the 0.1
conversion factor anymore as we don't seem to need it anymore.
Floating point numbers can always round down just as well as up. So
if you don't have exact integer values stored, but you want to
extract the nearest integer value, the intrinsic NINT() is probably
what you want. Also NINT() is supposed to work in the borderline
cases where adding a fudge factor before truncation fails due to
roundoff. NINT() has been in the language since f77.
$.02 -Ron Shepard
.
- References:
- storing an integer in a double precision
- From: Lynn McGuire
- Re: storing an integer in a double precision
- From: Richard Maine
- Re: storing an integer in a double precision
- From: Lynn McGuire
- Re: storing an integer in a double precision
- From: Lynn McGuire
- storing an integer in a double precision
- Prev by Date: Re: gotos in Fortran 95
- Next by Date: Re: storing an integer in a double precision
- Previous by thread: Re: storing an integer in a double precision
- Next by thread: Re: storing an integer in a double precision
- Index(es):
Relevant Pages
|