4 Jun 2013 average   » (Observer)

For anyone who wants to implement an arbitrary-precision integer library, the best technique (I'll argue) is to use simple strings and base256 encoding, gulped at word-sized intervals, dependent on machine architecture. On a 64-bit machine, that means we get to calculate 8 bytes at a time! Kickass.

Techniques for translating back and forth between base256 and base10 (for user I/O) are simple and well-known, but all the calculations will be done at near native CPU integer speed with minimal effort between gulps. Of course, things should be implemented with an eye for good cache performance.

For "floating point" or real-number arithmetic, a simple Rational class/struct implemented with two BigInts (numerator and denominator) can create a lossless, full-browed, real-number library.

Let me know if this is redundant.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!