Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Large integer implementation

Name: Anonymous 2011-01-02 8:27

Why do many large integer libraries store their data as a string of symbols instead of a block of integers native to the system? It seems to me that this would make bitwise operations rather difficult to implement.

Name: Anonymous 2011-01-02 8:31

I don't know how "many" many is, but most of the implementations I've seen tend to store bignums as some sort of packed bit arrays. Most C-based ones do provide string input as C doesn't support bignums natively and has no way of modifying the compiler to read something in as a static bignum. In languages with native bignum support (for example Common Lisp), bignums tend to be stored and inputted in saner manners (packed bit arrays).

Name: Anonymous 2011-01-02 8:41

The only implementation I've seen that is so stupid is FGInt, which sometimes uses temporary strings like "101010101" for 341.

Name: Anonymous 2011-01-02 8:45

>>2
You are right, I only looked for libraries in C and found several using char arrays. I also found a tutorial and their algorithms were only usable on strings.

I've implemented bitwise operators and schoolbook addition with carry / subtraction with borrowing so far.

Do you know how I could implement large integer operations such as modulo on blocks of 64bits?

Name: Anonymous 2011-01-02 17:00

Stop trying to implement RSA and get someone else to do your homework for you.

GMP uses an array of machine words for speed reasons. GNU bc uses a char array of decimal digits.

To not answer your question, see The Art of Computer Programming, vol. 2: Seminumerical Algorithms by Donald Knuth.

I find this page informative: http://www.codeproject.com/KB/cs/biginteger.aspx

Name: Anonymous 2011-01-02 17:07

>>5
There's plenty of decent bignum libs for C, and most provide some sort of powmod function (a**b mod n) which is what you usually need for fast RSA encryption/decryption.

Don't change these.
Name: Email:
Entire Thread Thread List