4 ms·
"I'm not ignorant" - of math operations in a computer, I'm afraid I have to contradict you. Using Strings to represent numbers is fine if you have all day. The
by hnriot 13y ago
"I'm not ignorant" - of math operations in a computer, I'm afraid I have to contradict you.
Using Strings to represent numbers is fine if you have all day. There are numerous libraries that perform Biginteger math - doing it as we're taught in grade school (in essence).
Number formats can be quite complex, for example, you might also want the byte layout to be lexically sortable (sort as 'characters' and end up with a numerically sorted list)
Refer to Knuth for how all this works.
- green7ea 13y agoJust to make sure this is clear: bigint libraries do not use strings. A well coded big int library will use an array of ints. When an overflow is detected (the processor has a flag for this) you expand the array appropriately. Some libraries don't wait to detect the overflow, in fact they compute how many bytes are required for a certain operation (easy to do with bitmasks) and allocate the appropriate size ahead of time (this is useful if you overflow often)