【发布时间】:2011-05-14 17:16:46
【问题描述】:
【问题讨论】:
【问题讨论】:
这篇文章很适合了解更多关于这个主题的信息:http://en.wikipedia.org/wiki/Integer_(computer_science)
所以问题的答案应该是: 从 -9,223,372,036,854,775,808 到 9,223,372,036,854,775,807, 或从 -(2^63) 到 2^63 - 1
存储在有符号整数中的最大正数表示为二进制
----- 63 个 -----
0111111111111111111111111111111111111111111111111111111111111111
如果你仔细想想,你会发现这个数字正好是 2^63 - 1。
【讨论】:
有符号整数的大小范围为 -2^(n-1) 到 2^(n-1) - 1,因此在这种情况下,最大值为 2 ^ 63 - 1 或 9,223,372,036,854,775,807
【讨论】:
Formula
2^(n-1) is the formula of the maximum value of a Bigint data type.
In the preceding formula N is the size of the data type. The ^ operator calculates the power of the value.
Now determine the value of N in Bit:
Select (max_length * 8) as 'Bit(s)' from sys.types Where name = 'BIGInt'
=64 Bits
范围::-9223372036854775808 到 9223372036854775807
【讨论】: