从十六进制数转换为十进制数 [英] Conversion from Hexadecimal number into Decimal number

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

问题描述

嗨朋友们,

我需要一个C语言示例代码,它会将十六进制

数转换为十进制数。我已经写了一个代码,但是它太长了,我需要一个小代码,所以请求你们给我提供

的小样本代码。

解决方案

dh **** ***@gmail.com 写道:


嗨朋友们,

我需要C中的示例代码才能转换一个十六进制的

到十进制数的数字。我已经写了一个代码,但是它太长了,我需要一个小代码,所以请求你们给我提供

的小样本代码。



u仍在度假。


你告诉我们你的,有人可能会告诉你他们的....


-

Ian Collins。


dh ******* @ gmail.com 说:


朋友们,

我需要C中的示例代码,它将十六进制

数转换为十进制数。



你问不可能。没有十六进制数这样的东西,并且

没有十进制数这样的东西。十六进制和十进制只是

表示。数字本身独立于基础。十几个苹果

是十几个苹果,不管你有多少个手指,无论你是不是把它写成1100,110,30,22,20, 15,14,13,12,11,10或

C.重要的是作者和读者都理解使用的

表示。 br />

您似乎要求的是如何将给定的表示形式

转换为另一种表示形式。这很容易做到。只需从您拥有的任何表示形式构建一个

整数n,然后执行此操作以在给定数字基础上构建

a表示:


s =空字符串

而n 0表示

digit = n mod base

将数字的文本表示添加到s
除以n为基础,给出n

elihw
如果s为空则为


s =" 0"

其他

反向到位

fi


-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:正常服务将尽快恢复。请不要

调整您的电子邮件客户端。


Richard Heathfield写道:

dh ******* @ gmail.com 说:


嗨朋友们,

我需要一个C中的示例代码,它会将十六进制

数转换为十进制数。



你问不可能的事。没有十六进制数这样的东西,并且

没有十进制数这样的东西。十六进制和十进制只是

表示。数字本身独立于基础。十几个苹果

是十几个苹果,不管你有多少个手指,无论你是不是把它写成1100,110,30,22,20, 15,14,13,12,11,10或

C.重要的是作者和读者都理解所使用的

表示。



我认为''打''本身就是另一种表现形式,这是一种非常随意的表现。我没有在大专以上学过数学,

但是让我问一下:除了某种形式的

表示之外,还能有数字吗?


Hi friends,
I need a sample code in C which will convert a Hexadecimal
number into decimal number. I had written a code for that but it was
too long, I need a small code, so request u all to provide me with
small sample code for that.

解决方案

dh*******@gmail.com wrote:

Hi friends,
I need a sample code in C which will convert a Hexadecimal
number into decimal number. I had written a code for that but it was
too long, I need a small code, so request u all to provide me with
small sample code for that.

u is still on holiday.

You show us yours and someone might show you theirs....

--
Ian Collins.


dh*******@gmail.com said:

Hi friends,
I need a sample code in C which will convert a Hexadecimal
number into decimal number.

You ask the impossible. There is no such thing as a hexadecimal number, and
no such thing as a decimal number. Hexadecimal and decimal are merely
representations. The number itself is independent of "base". A dozen apples
is a dozen apples, no matter how many fingers you have, and no matter
whether you write it as 1100, 110, 30, 22, 20, 15, 14, 13, 12, 11, 10, or
C. All that matters is that writer and reader(s) both understand the
representation being used.

What you appear to be asking for is how to convert a given representation
into another representation. That''s easy enough to do. Simply build an
integer n from whichever representation you have, and then do this to build
a representation in a given number base:

s = empty string
while n 0 do
digit = n mod base
add text representation of digit to the end of s
divide n by base, giving n
elihw
if s is empty
s = "0"
else
reverse s in place
fi

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: normal service will be restored as soon as possible. Please do not
adjust your email clients.


Richard Heathfield wrote:

dh*******@gmail.com said:

Hi friends,
I need a sample code in C which will convert a Hexadecimal
number into decimal number.


You ask the impossible. There is no such thing as a hexadecimal number, and
no such thing as a decimal number. Hexadecimal and decimal are merely
representations. The number itself is independent of "base". A dozen apples
is a dozen apples, no matter how many fingers you have, and no matter
whether you write it as 1100, 110, 30, 22, 20, 15, 14, 13, 12, 11, 10, or
C. All that matters is that writer and reader(s) both understand the
representation being used.

I would argue that ''dozen'' itself is another representation, albiet a
very arbitrary one. I''ve not studied mathematics beyond junior college,
but let me ask this: Can there be numbers apart from some form of
representation?


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

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