>>>> "Jerome" == Jerome H Fine
<jhfinexgs2 at compsys.to> writes:
Jerome> I have been having some fun with Prime Numbers using FORTRAN
Jerome> 77 under RT-11 on a PDP-11. Since I rapidly run out of the
Jerome> capacity of 32 bit numbers (INTEGER * 4 NUMBER), I have
Jerome> started to use 64 bit values (REAL * 8 NUMBER) but the
Jerome> conversion routines leave a lot to be desired on output.
Jerome> When using F32.0, I can count on only about 15 digits of
Jerome> accuracy even though the values are often accurate to an
Jerome> exact integer.
Of course. Just because it's exactly representable as an integer
doesn't mean it's exactly representable as a 64 bit float. Those have
a 56 bit mantissa, which means you have 2^56 bits of resolution, which
translates to roughly 16 digits. (The VAX architecture handbook
mentions that explicitly, by the way.)
Jerome> If needed, I can write my own conversion routines, but I
Jerome> though I might inquire if anyone knows of any libraries which
Jerome> are exact or better still, multi-precision libraries which
Jerome> can handle up to 128 bit integers?
If you want exact arithmetic, run, don't walk, away from floating
point numbers. Use only integers.
There the GNU MP library, and others like it. Long integer arithmetic
libraries are commonly found in crypto library packages. Come to
think of it, you'll find functions that are helpful in stuff relating
to prime numbers -- since prime numbers also figure prominently in
cryptography.
So you could use MP (which is in C) directly, given a suitable
compiler. Or you could port it to Fortran...
paul