*** Welcome to piglix ***

Powers of two


In mathematics, a power of two means a number of the form 2n where n is an integer, i.e. the result of exponentiation with number two as the base and integer n as the exponent.

In a context where only integers are considered, n is restricted to non-negative values, so we have 1, 2, and 2 multiplied by itself a certain number of times.

Because two is the base of the binary numeral system, powers of two are common in computer science. Written in binary, a power of two always has the form 100…000 or 0.00…001, just like a power of ten in the decimal system.

Verbal expressions, mathematical notations, and computer programming expressions using a power operator or function include:

Two to the power of n, written as 2n, is the number of ways the bits in a binary word of length n can be arranged. A word, interpreted as an unsigned integer, can represent values from 0 (000…0002) to 2n − 1 (111…1112) inclusively. Corresponding signed integer values can be positive, negative and zero; see signed number representations. Either way, one less than a power of two is often the upper bound of an integer in binary computers. As a consequence, numbers of this form show up frequently in computer software. As an example, a video game running on an 8-bit system might limit the score or the number of items the player can hold to 255—the result of using a byte, which is 8 bits long, to store the number, giving a maximum value of 28 − 1 = 255. For example, in the original Legend of Zelda the main character was limited to carrying 255 rupees (the currency of the game) at any given time, and the video game Pac-Man famously shuts down at level 255.


...
Wikipedia

...