I\'ve got four unsigned 32-bit integers representing an unsigned 128-bit integer, in little endian order:
typedef struct {
unsigned int part[4];
} bigint
If your values are mostly less than ULLONG_MAX
(18446744073709551615) I'd try to use for them sprintf(buf,"%llu",ullong_val)
. I bet this is rather well optimized in standard library, but parsing of format will take some cycles though.
Otherwise I'd create a bigint_divmod1000000000
(or better name mod10to9) function and use that. It would need 9 times less divides than bigint_divmod10
.