46

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.

João Pinto Jerónimo
  • 9,586
  • 15
  • 62
  • 86

3 Answers3

87

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.

Lakey
  • 1,948
  • 2
  • 17
  • 28
user561749
  • 1,029
  • 9
  • 6
  • 3
    Also, check out the Wikipedia page: [9223372036854775807](https://en.wikipedia.org/wiki/9223372036854775807) – Garrett Dec 13 '14 at 22:49
  • 1
    like your 63 ones comment, was about to count :) – user1767754 Aug 11 '16 at 07:38
  • @user1767754 don't review code based on comments. ;) –  Dec 01 '16 at 04:45
  • 4
    Or, in a speak-friendly version: nine quintillion two hundred twenty three quadrillion three hundred seventy two trillion thirty six billion eight hundred fifty four million seven hundred seventy five thousand eight hundred and seven :-) – Ted Aug 10 '20 at 09:03
  • 9.2 Exabytes. http://highscalability.com/blog/2012/9/11/how-big-is-a-petabyte-exabyte-zettabyte-or-a-yottabyte.html – SteveS May 07 '21 at 00:10
9

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

zellio
  • 31,308
  • 1
  • 42
  • 61
1
    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

Code
  • 679
  • 5
  • 9