Standard C/C++ library does not offer any means to manipulate large integer numbers (with unlimited precision).
However, the good news is, there are many third-party libraries available that will help you with the task.
One of the most simple and straightforward is freeware C++ BigInt - http://sourceforge.net/projects/cpp-bigint/
Once you integrate it into your project, you can easily work with big-int objects to multiply 2 integers or to perform other tasks.
For example:
...
RossiBigInt a ("2045782975296759229525", DEC_DIGIT);
RossiBigInt b ("9435789437592057295123, DEC_DIGIT);
RossiBigInt product = a * b;
cout << product << endl;
2007-11-13 05:58:22
·
answer #1
·
answered by General Cucombre 6
·
1⤊
0⤋
What you have to do is package the 100 bit integers into 32 bit integers (so, 4 integers using 128 bits of memory total). Then you start with the lowest 32 bits, add them, keep track of the carry bit, and then continue with the next 32 bits, applying the carry bit where necessary. This can't be done in pure C, you need to use assembler. Another option is to store the integers as character strings and perform the math bit by bit on each character working your way towards a solution.
2007-11-13 14:29:31
·
answer #2
·
answered by Pfo 7
·
1⤊
1⤋
You better use pencil and paper, cause that's too many bits.
2007-11-13 13:46:00
·
answer #3
·
answered by jimmymae2000 7
·
0⤊
4⤋