tags:

views:

43

answers:

2

In GMP library....

how does internal execution of operations on integers ll be done?? like 6=0110,4=0100..and 6+4= 0110+0100.. what happens in case of multiplications,division and other operations!?? how does it controls overflow bits and other things ...

A: 

No... im not asking about ALGORITHMS... internal bit operations... handling overflow of raw bits!!

kishorebjv
A: 

Most basic multiple-precision routines are written in assembly code and take advantage of specific CPU instructions.

For addition, the basic instruction is "ADD-with-Carry". This instruction will add the contents of two CPU registers and the carry bit, and then saves the result in a register and sets the carry bit if there was overflow. To add two multiple-precision numbers, the carry bit is cleared, then the first word (usually a C "unsigned int" or "unsigned long") in each multiple- precision value is added, the result saved, and the carry bit set for the next loop. The details are in handling different sized inputs, etc.

For multiplication, the basic instruction "MULT" just multiplies two registers and stores the upper half of the result in one CPU register and the lower half of the result in another CPU register.

For details on how it is actually done on a CPU, you'll need to research the CPU's instruction set.

casevh