Re: storing an integer in a double precision

Lynn McGuire <lmc@xxxxxxxxxx> wrote:

Is there a rule of thumb for the biggest integer that
I can store in a double precision variable without losing
the integer value due to round off ? BTW, I use a F77
compiler.

No particular "rule of thumb". Just look at the particular
representations. It doesn't have much to do with the version of Fortran,
but with the physical representation used for double precision (and, to
a lesser extent for integer, except that you won't run into any machines
that store integers in other than binary). Heck, it barely even has to
do with Fortran. (A little, but barely; the little has to do with how
Fortran compilers could select from different physical representations
supported by the hardware).

Look at how many bits are in the mantissa of the representation for
double. That's about how large an integer you could store without
roundoff. If you want the exact number, you have to look more carefully
and consider things like hidden bits (and on old IBM mainframes,
exponent radix). But for a rough approximation, just look at the number
of bits in the mantissa.

Most compilers these days use IEEE double, which has, if I recall
correctly, 53 bits in the mantissa. So your answer would be somewhere
around 2**53.

--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
.

Relevant Pages

• Re: storing an integer in a double precision
... I can store in a double precision variable without losing ... but with the physical representation used for double precision (and, ... of bits in the mantissa. ... that were converted but without roundoff? ...
(comp.lang.fortran)
• Print statement within If-Then block changes output!!!????
... I'm new to fortran, and I'm having a problem tracking a bug in my ... I have a pair of If-then blocks to store a minimum residual. ...
(comp.lang.fortran)
• Re: fortran reading a line
... of the loop there was no need to store it. ... Fortran 77 and later compilers to just store N+1 if there ... C does it character by character (as in stream I/O), ...
(comp.lang.fortran)
• Re: storing an integer in a double precision
... I can store in a double precision variable without losing ... It doesn't have much to do with the version of Fortran, ... Fortran compilers could select from different physical representations ... do double precision variables actually store 32 bit integers ...
(comp.lang.fortran)
• Re: Applesoft: find address that variable is stored at?
... anyone have a better explanation of the 5 byte representation? ... format works like this: ... the mantissa is stored in the other four bytes. ... Since this is always known to be the case, we don't have to actually store these bits anywhere. ...
(comp.sys.apple2.programmer)