为什么会出现多一个负INT不是积极的诠释? [英] Why is there one more negative int than positive int?

查看:207
本文介绍了为什么会出现多一个负INT不是积极的诠释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上限为任何 INT 数据类型(不包括 TINYINT ),始终是一个比的绝对值的下限。

The upper limit for any int data type (excluding tinyint), is always one less than the absolute value of the lower limit.

例如,对于一个上限 INT 为2,147,483,647和ABS(下限)= 2,147,483,648。

For example, the upper limit for an int is 2,147,483,647 and ABS(lower limit) = 2,147,483,648.

时有一个原因总是有比正面INT多了一个负面的诠释?

Is there a reason why there is always one more negative int than positive int?

编辑:由于问题改变的是没有直接关系的DB

推荐答案

您提供的类型符号整数。让我们来看看一个字节(8位)的例子。有了1个字节你有 2 ^ 8 它给你256个可能的数字存储组合。

The types you provided are signed integers. Let's see one byte(8-bit) example. With 1 byte you have 2^8 combinations which gives you 256 possible numbers to store.

现在你想拥有相同数量的正数和负数的(每组应有128)。

Now you want to have the same number of positive and negative numbers (each group should have 128).

问题的关键是 0 没有 + 0 -0 。世界上只有一个 0

The point is 0 doesn't have +0 and -0. There is only one 0.

所以,你最终范围 -128 ..- 1..0..1..127

同样的逻辑也适用于 16/32/64位

编辑:

为什么范围为 -128到127

这要看你如何 重新present符号整数


  • 签名幅度再presentation

  • 一补数

  • 两补

这篇关于为什么会出现多一个负INT不是积极的诠释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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