mersenneforum.org Calculating large numbers
 Register FAQ Search Today's Posts Mark Forums Read

 2010-03-26, 04:21 #1 Historian     Mar 2010 43 Posts Calculating large numbers I haven't taken many computer science classes, so could someone explain how GIMPS and other prime searching products store and sieve such large numbers? Long ago, I remember reading somewhere that a short int only goes from -32768 to +32768, long int goes from -2^31 to 2^31, and even double precision float for positive numbers only goes from 10^-308 to 10^308. I think this was using C++, but I'm guessing other programming languages also don't have limits that are high enough to accomodate a number such as 12345*2^1000000-1.
 2010-03-26, 05:50 #2 S485122     Sep 2006 Brussels, Belgium 32068 Posts You could start by looking at the explanations on the PrimeNet page The Maths, there are some links there if you want more explanation. Otherwise a search on Internet of "Arbitrary precision arithmetic" will return many links (Wikipedia, Wolfram MathWorld...) One interesting link is Arbitrary precision computation. Jacob Last fiddled with by S485122 on 2010-03-26 at 05:58 Reason: removed a hyphen and added another link
2010-03-26, 13:33   #4
R.D. Silverman

Nov 2003

1D2416 Posts

Quote:
 Originally Posted by Historian I haven't taken many computer science classes, so could someone explain how GIMPS and other prime searching products store and sieve such large numbers? Long ago, I remember reading somewhere that a short int only goes from -32768 to +32768, long int goes from -2^31 to 2^31, and even double precision float for positive numbers only goes from 10^-308 to 10^308. I think this was using C++, but I'm guessing other programming languages also don't have limits that are high enough to accomodate a number such as 12345*2^1000000-1.
Read D. Knuth, The Art of Computer Programming, Vol II.

As to how large numbers are stored: Think "arrays"

 2010-03-26, 19:39 #5 Historian     Mar 2010 43 Posts Thanks for the help guys.

 Similar Threads Thread Thread Starter Forum Replies Last Post Merfighters Miscellaneous Math 2 2010-10-29 16:51 SQUARE Information & Answers 7 2009-05-10 09:13 Mini-Geek Programming 10 2008-07-31 17:04 Elhueno Homework Help 5 2008-06-12 16:37 Bundu Software 5 2004-08-26 01:56

All times are UTC. The time now is 04:35.

Mon May 17 04:35:25 UTC 2021 up 38 days, 23:16, 0 users, load averages: 1.68, 2.30, 2.65