有符号整数与无符号整数 [英] Signed versus Unsigned Integers

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

问题描述

我是否正确地说有符号整数和无符号整数之间的区别是:

Am I correct to say the difference between a signed and unsigned integer is:

  1. 无符号可以容纳更大的正值,而没有负值.
  2. 无符号使用前导位作为值的一部分,而有符号版本使用最左边的位来识别数字是正数还是负数.
  3. 有符号整数可以同时包含正数和负数.

还有其他区别吗?

推荐答案

无符号可以容纳更大的正值,没有负值.

Unsigned can hold a larger positive value and no negative value.

是的.

无符号使用前导位作为值的一部分,而有符号版本使用最左边的位来识别数字是正数还是负数.

Unsigned uses the leading bit as a part of the value, while the signed version uses the left-most-bit to identify if the number is positive or negative.

有不同的方式来表示有符号整数.最容易可视化的是使用最左边的位作为标志(符号和幅度),但更常见的是二的补码.两者都在大多数现代微处理器中使用——浮点使用符号和幅度,而整数运算使用二进制补码.

There are different ways of representing signed integers. The easiest to visualise is to use the leftmost bit as a flag (sign and magnitude), but more common is two's complement. Both are in use in most modern microprocessors — floating point uses sign and magnitude, while integer arithmetic uses two's complement.

有符号整数可以同时包含正数和负数.

Signed integers can hold both positive and negative numbers.

是的.

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

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