Fastest way to convert binary to decimal?

前端 未结 6 1643
花落未央
花落未央 2020-12-16 05:21

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         


        
6条回答
  •  無奈伤痛
    2020-12-16 05:57

    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.

提交回复
热议问题