How big can a 64bit signed integer be?

2019-03-14 07:42发布

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. I'm sorry if this is common knowledge, my background is Economics and no one told me the answer to the question there.

Thanks in advance :)

标签: integer 64bit
2条回答
Bombasti
2楼-- · 2019-03-14 07:59

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

查看更多
We Are One
3楼-- · 2019-03-14 08:19

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.

查看更多
登录 后发表回答