将负整数转换为八进制/十六进制 [英] Converting negative integer to octal/hexadecimal

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

问题描述

如何将负整数转换为十六进制或八进制数?


Ex:-568


等效的十六进制和八进制数是多少??

How to convert negative integer to hexadecimal or octal number?

Ex: -568

What is the equivalent hexadecimal and octal number??

推荐答案

jaks.ma ... @ gmail.com写道:
jaks.ma...@gmail.com wrote:
如何转换负整数到十六进制或八进制数?

Ex:-568

等效的十六进制和八进制数是多少?
How to convert negative integer to hexadecimal or octal number?

Ex: -568

What is the equivalent hexadecimal and octal number??




+568 = hex ... 0000238 = 2 * 16 ^ 2 + 3 * 16 + 8

-568 = hex ... FFFFDC8,验证总和为零。


+568 = oct ... 0001070 = 8 ^ 3 + 7 * 8

-568 = oct ... 7776710,验证总和为零。 />
-



+568 = hex ...0000238 = 2 * 16^2 + 3 * 16 + 8
-568 = hex ...FFFFDC8, verify the sum is zero.

+568 = oct ...0001070 = 8^3 + 7 * 8
-568 = oct ...7776710, verify the sum is zero.
--



ja ******** @ gmail.com 写道:
如何将负整数转换为十六进制或八进制数?

Ex :-568

等效的十六进制和八进制数是多少R 14


这是一个C问题怎么样?


即使它是,你还不够精确。你的意思是1'或2'的

补充,符号加绝对价值?你的数字是多少位

是什么?

我从哪里开始,以下程序:
How to convert negative integer to hexadecimal or octal number?

Ex: -568

What is the equivalent hexadecimal and octal number??
And how is this a C question?

Even if it were, you were not precise enough. Do you mean 1''s or 2''s
complement, sign-plus-absolute value? How many bits wide your numbers
are?
From where I sit, the following program:




#包括< stdio.h>


int main(无效)

{

int i = -568;


printf(" i =%x \ n",i);


返回0;

}


产生以下结果:


i = fffffdc8




#include <stdio.h>

int main( void )
{
int i = -568;

printf("i = %x\n", i);

return 0;
}

produces the following:

i = fffffdc8

[FYI: that''s 32 bit 2''s complement. YMMV.]


< ja ******** @ gmail.com>写道:
<ja********@gmail.com> wrote:
如何将负整数转换为十六进制或八进制数?

Ex:-568

等效的十六进制数是多少和八进制数??
How to convert negative integer to hexadecimal or octal number?

Ex: -568

What is the equivalent hexadecimal and octal number??




转换不是很正确的单词。在行业中使用的,八进制和十六进制

是数字的*表示*。选择你的号码和编码

技术,用二进制写它(也许在纸上)然后八进制和十六进制是

快速通信的方式,大多数人,二进制号码你是说b $ b。至少有三种方式代表负数
数字:一个补码,两个补码和符号和数量(使用

符号框)。对于你的样品编号,它们都会有所不同。


如果这让你烦恼,可以考虑一件东西和一张图片之间的区别




Convert is not quite the right word. As used in the industry, octal and hex
are *representations* of numbers. Choose your number and a coding
technique, Write it (perhaps on paper) in binary and then octal and hex are
shortcut ways of communicating, to people mostly, the binary number you are
speaking of. There are at least three ways of representing negative
numbers: one complement, twos complement and sign and magnitude (using a
"sign box"). They would all be different for your sample number.

If that bothers you, think of the difference between a thing and a picture
of that thing.


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

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