簡體   English   中英

64 位有符號整數可以有多大?

[英]How big can a 64bit signed integer be?

redis 中

HINCRBY 支持的值范圍僅限於 64 位有符號整數。

我想知道 64 位有符號整數有多大。

這篇文章是關於這個主題的更多信息: 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM