C中的大十进制到十六进制转换 [英] Large Decimal to Hex Conversion in C

查看:92
本文介绍了C中的大十进制到十六进制转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,我需要将一个大的十进制值更改为

其十六进制等效值。我需要表示的最大十进制值为
hex是25516777215.这里的问题是这个数字比任何C函数都能处理的数字更大。任何有关如何去讨论这个问题的建议都将不胜感激。


谢谢,

布拉德。

I have a problem in that I need to change a large decimal value into
its hex equivalent. The largest decimal value I need to represent as
hex is 25516777215. The problem here is that this number is larger
than any of the C functions can handle. Any suggestions on how to go
about this would be appreciated.

Thanks,
Brad.

推荐答案

Brad写道:
我有一个问题,我需要将一个大的十进制值更改为其十六进制等效值。我需要表示为十六进制的最大十进制值是25516777215.这里的问题是这个数字比任何C函数都能处理的要大。关于如何去了解这个的任何建议将不胜感激。
I have a problem in that I need to change a large decimal value into
its hex equivalent. The largest decimal value I need to represent as
hex is 25516777215. The problem here is that this number is larger
than any of the C functions can handle. Any suggestions on how to go
about this would be appreciated.




获得一个大数量的图书馆?


您是否将数字作为ASCII字符串开头?如果只是

只需读取它很长一段时间然后执行简单的div / mod来获得

位数。


如果不是,你必须更聪明[minimal hexbignum math :-)]


Tom



Get a big num library?

Do you have the numbers as an ASCII string to begin with? If so than
just read it to a long long and then do the trivial div/mod to get the
digits.

If not you will have to be more clever [minimal hexbignum math :-)]

Tom




" Brad" <峰; br ****** @ mobility.com>在消息中写道

新闻:7f ************************** @ posting.google.c om ...

"Brad" <br******@mobility.com> wrote in message
news:7f**************************@posting.google.c om...
我有一个问题,我需要将一个大的十进制值更改为其十六进制等效值。我需要表示为十六进制的最大十进制值是25516777215.这里的问题是这个数字比任何C函数都能处理的要大。关于如何去讨论这个问题的任何建议都将不胜感激。
I have a problem in that I need to change a large decimal value into
its hex equivalent. The largest decimal value I need to represent as
hex is 25516777215. The problem here is that this number is larger
than any of the C functions can handle. Any suggestions on how to go
about this would be appreciated.




对于数量这么大的数字而言,在一些部分并不难做到将

数字放在一起。我以为你的意思是数千或数百万美元的数字。


但是,这是一个非常奇怪的数字。请注意,16777215十进制是

X''ffffff''和255十进制是X''ff'',所以它并不是很明显为什么

25500000000+ 16777215将是你感兴趣的最大数字。


如果你除以16777216你得到更高的十六进制数字,%16777216

你得到了低位数。打印两个没有领先的零压力和

它看起来像一个数字。


- glen



For numbers that size it isn''t hard to do it in a few parts and put the
numbers together. I thought you meant ones with thousands or millions of
digits.

That is, though, a very strange number. Note that 16777215 decimal is
X''ffffff'' and 255 decimal is X''ff'', so it isn''t at all obvious why
25500000000+16777215 would be the largest number you are interested in.

If you divide it by 16777216 you get the higher hex digits, and % 16777216
you get the low digits. Print the two without leading zero supression and
it will look like one number.

-- glen


br******@mobility.com (Brad)写道:
br******@mobility.com (Brad) wrote:
我有一个问题,我需要将一个大的十进制值更改为其十六进制等效值。我需要表示的最大十进制值为<是25516777215.这里的问题是这个数字更大


~25亿美元将适合''long long' '(64 =< bits)变量。一个编译器

支持l; ong long可能有printf等实现

可以处理这些值。

比任何一个C功能可以处理。关于如何去讨论关于这个的任何建议都将不胜感激。

谢谢,
布拉德。
I have a problem in that I need to change a large decimal value into
its hex equivalent. The largest decimal value I need to represent as
hex is 25516777215. The problem here is that this number is larger
~25 billion will fit into a ''long long'' (64=< bits) variable. A compiler
which supports l;ong long will probably have printf etc. implementations
that can handle these values.
than any of the C functions can handle. Any suggestions on how to go
about this would be appreciated.

Thanks,
Brad.






这篇关于C中的大十进制到十六进制转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆