我如何在c中将一个非常大的十六进制数转换为十进制数组?
我如何在c中将一个非常大的十六进制数转换为十进制数组?
unsigned char hexnr[32]={0xa5,0xe0,0x43,0xe4,0x10,0xb7,0x3a,0x7e,0xdf,0xba,0xec,0x78,0x52,0x82,0xfd,0xd2,0xea,0x43,0xec,0x53,0xdb,0x24,0xbc,0xdd,0xbb,0x5d,0x2c,0xc4,0x45,0x98,0xad,0x16};
char ResultInDecimals[]={7,5,0,2,7,8,6,2,3,2,4,3,8,2,7,5,9,7,4,8,5,4,6,3,7,0,0,5,2,4,2,8,7,7,3,5,3,6,8,3,3,3,8,0,8,1,9,0,5,7,1,1,6,5,1,9,1,5,2,0,5,5,4,7,0,7,8,7,6,2,5,7,9,0,7,4,2};
十六进制: 0xa5e043e410b73a7edfbaec785282fdd2ea43ec53db24bcddbb5d2cc44598ad16
十进制: 75027862324382759748546370052428773536833380819057116519152055470787625790742
how can i in c convert a very big hex number into an array of decimals?
unsigned char hexnr[32]={0xa5,0xe0,0x43,0xe4,0x10,0xb7,0x3a,0x7e,0xdf,0xba,0xec,0x78,0x52,0x82,0xfd,0xd2,0xea,0x43,0xec,0x53,0xdb,0x24,0xbc,0xdd,0xbb,0x5d,0x2c,0xc4,0x45,0x98,0xad,0x16};
char ResultInDecimals[]={7,5,0,2,7,8,6,2,3,2,4,3,8,2,7,5,9,7,4,8,5,4,6,3,7,0,0,5,2,4,2,8,7,7,3,5,3,6,8,3,3,3,8,0,8,1,9,0,5,7,1,1,6,5,1,9,1,5,2,0,5,5,4,7,0,7,8,7,6,2,5,7,9,0,7,4,2};
in hex : 0xa5e043e410b73a7edfbaec785282fdd2ea43ec53db24bcddbb5d2cc44598ad16
out decimal : 75027862324382759748546370052428773536833380819057116519152055470787625790742
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本运算是将 32 位 256 基数除以 10 并得到余数。
从结果中,我注意到“十六进制”数字和结果都首先存储最高有效数字。因此,除法可以实现如下:
将其应用于给定的示例可以如下完成:
打印结果:
The basic operation is to divide the 32-digit base 256 number with 10 and get the remainder.
From the result, I notice that both the "hex" number and the result are stored with the most significant digit first. Hence the division method can be implemented as follows:
Applying this to the given example can be done like this:
which prints the result: