Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How big can a 64bit signed integer be?

Tags:

integer

64-bit

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.

like image 935
João Pinto Jerónimo Avatar asked May 14 '11 17:05

João Pinto Jerónimo


People also ask

What's the maximum size of a signed integer?

A signed integer is a 32-bit datum that encodes an integer in the range [-2147483648 to 2147483647].

How many decimal digits could be stored in a signed 64-bit integer?

A 64-bit register can hold any of 264 (over 18 quintillion or 1.8×1019) different values. The range of integer values that can be stored in 64 bits depends on the integer representation used.


2 Answers

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.

like image 174
user561749 Avatar answered Sep 27 '22 15:09

user561749


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

like image 23
zellio Avatar answered Sep 27 '22 16:09

zellio