Image

Imagepeaceful_dragon wrote in Imagecpp

128 or 256 bit numbers?

Does anybody know of a better way to represent 128 or 256 bit numbers?

I've been using four 32-bit unsigned integers to represent 128 bit numbers (and eight for 256 bits), but there has to be a better way. It's so clunky to have to deal with four/eight components when it's really logically just one. (e.g. if I increment the number, I have to carry the one across all four components if it overflows, etc.)

For example, to represent 0x44444444333333332222222211111111 I have to do:

unsigned int slice0 = 0x11111111;
unsigned int slice1 = 0x22222222;
unsigned int slice2 = 0x33333333;
unsigned int slice3 = 0x44444444;

The reason? I'm modelling microprocessors, which often have internal buses of 128 or 256 bits nowadays (or even more).

Maybe there is a library for this kind of stuff?

Thanks in advance!