First of all, the reason is "FOR FUN", the most practical of all reasons.
Second, the basic problem is that the FORTRAN 77 routines for the
PDP-11 under RT-11 are not even accurate beyond about 12 places
of precision using FORTRAN 77 floating point conversions. So even
if the value is correct internally to the 56 bit mantissa of the 64 bit
floating point value, it is not possible to depend on the displayed result.
Third, arbitrary precision routines have too much precision relative to
what I actually require most of the time - which is only about 80 to 120
bits for integers. The area I am interested in is probably best described
by the information at:
which has a 22 digit number as the biggest value in all the tables there.
So 128 bit integers which require only 16 bytes are more than sufficient.
The required subroutines are easy to code in MACRO-11 and will be
suitable for what I need without the added overhead of subroutines that
can handle numbers with thousands of digits, let along millions. The
biggest problem that I have encountered thus far was how to encode
such a large integer for output. The standard method for small numbers
is to just subtract powers of ten. But I needed a table of 16 bit values
to place in each if the approximately 38 entries in the table, each entry
being 8 * 16 bit words. So I just used the subroutine that performs
addition on 128 bit values to produce the powers of ten and then
use the FORTRAN 77 octal output to write the 8 word entries to a
file. That file was then used in the MACRO-11 program. Actually
quite a reasonable way to let the computer do the accounting details
while I did the program to use the table.
I realize that I omitted the actual size of the words I want to work
with ( i.e. 128 bit integers) which are actually quite small compared
to the really huge stuff which deals with and handles values with over
a million decimal digits. For that, I apologize.
Best regards, Jerome Fine
Jonathan Laventhol wrote:
Hi All --
Regarding primes ...
If anyone has any suggestions, they would be
appreciated!
I think we tried to direct you in the past towards arbitrary precision
integer arithmetic for your calculations, as you chose to deviate
from that it is my belief, at least, that you chose to waste your
own time.
I say read Knuth instead. Just reading a section on largest known
primes
in the form of 2^n -1 you get some rather big numbers: 2^20996011 - 1 is
6,300,000 decimal digits.
Ben alias woodelf
I believe there's no way to do anything at all with primes unless
all your numbers are accurate to (at least) 2^0, that is, they
are integers. (Otherwise you don't even know if they're even or odd!)
So if you're using floating point numbers, you are limited to
the size of your mantissa; which might be a convenient way to
get something bigger than 32 bits, but it won't get you any
bigger than your mantissa. (Well, you get one bit for free
if your floating point representation uses the implied leading
zero.)
So I'm with the others: Knuth + arbitrary precision. There
are some other good books on specifically arithmetic with
primes.
May I ask what it's for?
Best regards,
J.