English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2 answers

use gmp/mpfr depending on whether you are restricting yourself to integers or floating point; both are written in C.

the reason being there is no need to reinvent the wheel
IF you are doing this as a programming project you can either check the source for both and proceed similarly or hack up your own idea that is a modification of either.

[you could also use miracl if you wanted; i also think David Bailey has a nice quad-precision and arbitrary precision implementation here http://crd.lbl.gov/~dhbailey/mpdist/ ]

as someone else noted Knuth gives a good idea of the fundamentals from umpteen years back - his new volume will be coming out "soon" (in relative terms that is) though it will deal with permutations/combinatorics for the most part i believe

2007-12-15 08:53:51 · answer #1 · answered by xkey 3 · 0 0

How accurate must the results be?

If the answer is, "not very", then just implement your own floating point package, with one 32-bit integer for the exponent and a longlong for the "mantissa"

http://en.wikipedia.org/wiki/Floating_point

If the answer is "medium", then use a byte string or integer array for the mantissa to the desired level of accuracy.

If you have to be exact, then the question is what are you going to do with these numbers? Are you really going to print out 46,000 digits?

If you need to do significant further computation, perhaps you should use a modulo representation:

http://cs.annauniv.edu/insight/insight/maths/algebra/indet/modrep.htm

You can use the Chinese remainder theorem to convert back:
http://en.wikipedia.org/wiki/Chinese_remainder_theorem

either way, 10^46000 is on the order of 2^150000 so you'll need approximately 20KB per number.

In any case, the authority on all of these algorithms is Donal Knuth's "The Art of Computer Programming vol 2"

2007-12-14 18:41:02 · answer #2 · answered by simplicitus 7 · 0 0

fedest.com, questions and answers