有符号和无符号整数? [英] Signed and unsigned integers?

查看:92
本文介绍了有符号和无符号整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以向我解释这两个问题吗,因为我必须在作业中对两者进行解释.

Could someone please explain the two to me because I have to give an explanation of them both in my assignment.

我知道什么是正常的整数,并使用以下内容对其进行描述:

I know what a normal integer is of course and have used the following to describe it:

整数是整数,可以为正,负和零,但不能有小数点."

"An integer is a whole number which can be positive, negative and zero but it cannot have decimal points."

但是我不确定签名和未签名.

But I'm just not sure about signed and unsigned.

谢谢

推荐答案

有符号整数和无符号整数之间的区别在于,需要整数的一个字节来保存符号.

The difference between a signed and unsigned integer is that one byte of the integer is required to hold the sign.

例如,使用两个二进制数字,您可以具有以下内容:

For instance, with two binary digits you can have the following:

Base 2   Base 10
00       0
01       1
10       2
11       3

但是,如果我们将第一位数字表示为负数(0)或正数(1)

However, if we take the first digit to mean negative (0) or positive (1)

Base 2   Base 10
01       -1
00       0
10       1
11       2

或者,如果我们希望1为负数,而0为正数:

Or, if we wanted 1 to be negatiave, and 0 to be positive:

Base 2   Base 10
01       1
00       0
10       -1
11       -2

要进一步阅读,请查看 Two's compliment

For further reading, check out the Wikepedia article on Two's compliment

这篇关于有符号和无符号整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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