Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why to use higher base for implementing BigInt?

I'm trying to implement BigInt and have read some threads and articles regarding it, most of them suggested to use higher bases (256 or 232 or even 264).

Why higher bases are good for this purpose?

Other question I have is how am I supposed to convert a string into higher base (>16). I read there is no standard way, except for base64. And the last question, how do I use those higher bases. Some examples would be great.

like image 258
questions Avatar asked Oct 19 '25 14:10

questions


1 Answers

The CPU cycles spent multiplying or adding a number that fits in a register tend to be identical. So you will get the least number of iterations, and best performance, by using up the whole register. That is, on a 32-bit architecture, make your base unit 32 bits, and on a 64-bit architecture, make it 64 bits. Otherwise--say, if you only fill up 8 bits of your 32 bit register--you are wasting cycles.

like image 135
StilesCrisis Avatar answered Oct 22 '25 02:10

StilesCrisis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!