Why is the maximum value of an unsigned n-bit integer 2ⁿ-1 and not 2ⁿ?

The -1 is because integers start at 0, but our counting starts at 1. So, 2^32-1 is the maximum value for a 32-bit unsigned integer (32 binary digits). 2^32 is the number of possible values. To simplify why, look at decimal. 10^2-1 is the maximum value of a 2-digit decimal number (99). Because our intuitive … Read more

How big can a 64bit signed integer be?

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 … Read more

Why is an int in OCaml only 31 bits?

This is called a tagged pointer representation, and is a pretty common optimization trick used in many different interpreters, VMs and runtime systems for decades. Pretty much every Lisp implementation uses them, many Smalltalk VMs, many Ruby interpreters, and so on. Usually, in those languages, you always pass around pointers to objects. An object itself … Read more

Signed versus Unsigned Integers

Unsigned can hold a larger positive value and no negative value. Yes. Unsigned uses the leading bit as a part of the value, while the signed version uses the left-most-bit to identify if the number is positive or negative. There are different ways of representing signed integers. The easiest to visualise is to use the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)