The real key to implementing bignums effectively is that you need to increase the multiplication, which gives you 2x as many times as your main word size. Thus, you can use uint64_t as the main word size if your platform supports a 128-bit multiplication result. The size of the pointers on your machine is largely irrelevant.
If you really want the most efficient implementation to be as portable as possible, you must make the word size selected at compile time. Then use an autoconfig script that (tries) to build code with different word sizes and checks the results of these builds for correctness and speed.
#define WORD_(SIZE) std::uint ## SIZE ## _t #define WORD(SIZE) WORD_(SIZE) #define X2_(SIZE) X2_ ## SIZE #define X2(SIZE) X2_(SIZE) #define X2_8 16 #define X2_16 32 #define X2_32 64 #define X2_64 128
use WORD(WORD_SIZE) and WORD(X2(WORD_SIZE)) in your code and compile with
-DWORD_SIZE=8 or 16 or 32 or 64
source share