How to convert a 128-bit integer to a decimal ascii string in C?

前端 未结 7 2210
小蘑菇
小蘑菇 2020-12-14 10:44

I\'m trying to convert a 128-bit unsigned integer stored as an array of 4 unsigned ints to the decimal string representation in C:

unsigned int src[] = { 0x1         


        
7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-14 11:18

    @Alexey Frunze's method is easy but it's very slow. You should use @chill's 32-bit integer method above. Another easy method without any multiplication or division is double dabble. This may work slower than chill's algorithm but much faster than Alexey's one. After running you'll have a packed BCD of the decimal number

提交回复
热议问题