By huge numbers, I mean if you took a gigabyte (instead of 4/8 bytes etc.) and tried to add/subtract/multiply/divide it by some other arbitrarily large (or small) number.
Adding and subtracting are rather easy (one k/m/byte at a time):
out_byteN = a_byteN + b_byteN + overflowBit
For every byte, thus I can add/subtract as I read the number from the disk and not risk running out of RAM.
For multiplying/dividing, simply do the above in a loop.
But what about taking the nth root of a HUGE number?
Are you asking for something like "The GNU Multiple Precision Arithmetic Library" (at http://gmplib.org/)?
Same as any other number: Newton iteration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With