64 位有符号整数可以有多大?

发布于 2024-11-07 06:08:06 字数 180 浏览 0 评论 0原文

redis 中,

支持的值范围 HINCRBY 仅限于 64 位有符号 整数。

我想知道 64 位有符号整数有多大。

In redis,

The range of values supported by
HINCRBY is limited to 64 bit signed
integers.

And I'd like to know how big can that 64 bit signed integer be.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

私藏温柔 2024-11-14 06:08:06

本文非常适合了解有关此主题的更多信息: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

存储在有符号 int 中的最大正数表示为二进制

----- 63 个 -----

0111111111111111111111111111111111111111111111111111111111111111

如果你仔细思考你可以发现这个数字正好是2^63 - 1。

This article is good for more information about this topic: http://en.wikipedia.org/wiki/Integer_(computer_science)

So the answer to the question should be:
From -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807,
or from −(2^63) to 2^63 − 1

The highest positive number stored in a signed int is represented binary as

----- 63 ones -----

0111111111111111111111111111111111111111111111111111111111111111

If you think carefully you can find out that this number is exactly 2^63 - 1.

叫嚣ゝ 2024-11-14 06:08:06

有符号整数的大小范围为 −2^(n−1) 到 2^(n−1) − 1,因此在这种情况下最大值将为 2 ^ 63 - 1 或 9,223,372,036,854,775,807

A signed integer ranges from size −2^(n−1) through 2^(n−1) − 1 so in this case the maximum value would be 2 ^ 63 - 1 or 9,223,372,036,854,775,807

北渚 2024-11-14 06:08:06
    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

    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

Range:: -9223372036854775808 to 9223372036854775807

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文