Power of two


Image:powers_of_two_cuboids.svg|thumb|Visualization of powers of two from 1 to 1024 as base-2 Dienes blocks
A power of two is a number of the form where is an integer, that is, the result of exponentiation with number two as the base and integer as the exponent. In the fast-growing hierarchy, is exactly equal to. In the Hardy hierarchy, is exactly equal to.
Powers of two with non-negative exponents are integers:,, and is two multiplied by itself times. The first ten powers of 2 for non-negative values of are:
By comparison, powers of two with negative exponents are fractions: for positive integer, is one half multiplied by itself times. Thus the first few negative powers of 2 are,,,, etc. Sometimes these are called inverse powers of two because each is the multiplicative inverse of a positive power of two.

Base of the binary numeral system

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 10 in the decimal system.

Computer science

Two to the power of, written as, is the number of values in which the bits in a binary word of length can be set, where each bit is either of two values. A word, interpreted as representing an integer in a range starting at zero, referred to as an "unsigned integer", can represent values from 0 to inclusively. An alternative representation, referred to as a signed integer, allows values that 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, allowing the representation of 256 distinct values from to. For example, in the original Legend of Zelda the main character was limited to carrying 255 rupees at any given time, and the video game Pac-Man famously has a kill screen at level 256.
Powers of two are often used to define units in which to quantify computer memory sizes. A "byte" now typically refers to eight bits, resulting in the possibility of 256 values. The prefix kilo, in conjunction with byte, has been used by computer scientists to mean . However, in general, the term kilo has been used in the International System of Units to mean . A series of binary prefixes has been standardized, including kibi meaning. Nearly all processor registers have sizes that are a power of two bits, 8, 16, 32 or 64 bits being very common, with the last two being most common except for very small processors.
Powers of two occur in a range of other places as well. For many disk drives, at least one of the sector size, number of sectors per track, and number of tracks per surface is a power of two. The logical block size is almost always a power of two.
Numbers that are closely related to powers of two occur in a number of computer hardware designs, such as with the number of pixels in the width and height of video screens, where the number of pixels in each direction is often the product of a power of two and a small number. For example,, and.

Mersenne and Fermat primes

A prime number that is one less than a power of two is called a Mersenne prime. For example, the prime number 31 is a Mersenne prime because it is 1 less than 32. Similarly, a prime number that is one more than a positive power of two is called a Fermat prime—the exponent itself is a power of two. A fraction that has a power of two as its denominator is called a dyadic rational. The numbers that can be represented as sums of consecutive positive integers are called polite numbers; they are exactly the numbers that are not powers of two.

Euclid's ''Elements'', Book IX

The geometric progression 1, 2, 4, 8, 16, 32,... is important in number theory. Book IX, Proposition 36 of Elements proves that if the sum of the first terms of this progression is a prime number, then this sum times the th term is a perfect number. For example, the sum of the first 5 terms of the series, which is a prime number. The sum 31 multiplied by 16 equals 496, which is a perfect number.
Book IX, Proposition 35, proves that in a geometric series if the first term is subtracted from the second and last term in the sequence, then as the excess of the second is to the first—so is the excess of the last to all those before it. Applying this to the geometric progression 31, 62, 124, 248, 496, we see that 62 minus 31 is to 31 as 496 minus 31 is to the sum of 31, 62, 124, 248. Therefore, the numbers 1, 2, 4, 8, 16, 31, 62, 124 and 248 add up to 496 and further these are all the numbers that divide 496. For suppose that divides 496 and it is not amongst these numbers. Assume is equal to, or 31 is to as is to 16. Now cannot divide 16 or it would be amongst the numbers 1, 2, 4, 8 or 16.
Therefore, 31 cannot divide. And since 31 does not divide and measures 496, the fundamental theorem of arithmetic implies that must divide 16 and be among the numbers 1, 2, 4, 8 or 16. Let be 4, then must be 124, which is impossible since by hypothesis is not amongst the numbers 1, 2, 4, 8, 16, 31, 62, 124 or 248.

First 64 powers of two

0[1 (number)|]16[65536 (number)|]32[4294967296 (number)|]48
1[2 (number)|]173349
2[4 (number)|]183450
3[8 (number)|]193551
4[16 (number)|]203652
5[32 (number)|]213753
6[64 (number)|]223854
7[128 (number)|]233955
8[256 (number)|]244056
9[512 (number)|]254157
10[1024 (number)|]264258
11[2048 (number)|]274359
12[4096 (number)|]284460
13[8192 (number)|]294561
14[16384 (number)|]304662
15[32768 (number)|]314763

Last digits

Starting with 2 the last digit is periodic with period 4, with the cycle 2–4–8–6–, and starting with 4 the last two digits are periodic with period 20. These patterns are generally true of any power, with respect to any base. The pattern continues where each pattern has starting point, and the period is the multiplicative order of 2 modulo, which is .

Powers of 1024

The first few powers of 210 are slightly larger than those same powers of . The first 11 powers of 210 values are listed below:
20=1= 10000
210=≈ 10001
220=≈ 10002
230=≈ 10003
240=≈ 10004
250=≈ 10005
260=≈ 10006
270=≈ 10007
280=≈ 10008
290=≈ 10009
2100=≈ 100010

It takes approximately 17 powers of 1024 to reach 50% deviation and approximately 29 powers of 1024 to reach 100% deviation of the same powers of 1000. Also see Binary prefixes and IEEE 1541-2002.

Powers of two whose exponents are powers of two

Because data and the addresses of data are stored using the same hardware, and the data is stored in one or more octets, double exponentials of two are common in computing. The first 21 of them are:
digits
0121
1241
24162
382563
416[65536 (number)|]5
532
664
7128
8256
9
10
11
12
13
14
15
16
17
18
19
20

Also see Fermat number, Tetration and .

Last digits for powers of two whose exponents are powers of two

All of these numbers over 4 end with the digit 6. Starting with 16 the last two digits are periodic with period 4, with the cycle 16–56–36–96–, and starting with 16 the last three digits are periodic with period 20. These patterns generally occur with any power, with respect to any base. The pattern continues where each pattern has starting point, and the period is the multiplicative order of 2 modulo, which is .

Facts about powers of two whose exponents are powers of two

In a connection with nimbers, these numbers are often called Fermat 2-powers.
The numbers form an irrationality sequence: for every sequence of positive integers, the series
converges to an irrational number. Despite the rapid growth of this sequence, it is the slowest-growing irrationality sequence known.

Powers of two whose exponents are powers of two in computer science

Since it is common for computer data types to have a size which is a power of two, these numbers count the number of representable values of that type. For example, a 32-bit word consisting of 4 bytes can represent distinct values, which can either be regarded as mere bit-patterns, or are more commonly interpreted as the unsigned numbers from 0 to, or as the range of signed numbers between and. For more about representing signed numbers see Two's complement.

Selected powers of two

; 22 = : The number that is the square of two. Also the first power of two tetration of two.
; 28 = : The number of values represented by the 8 bits in a byte, more specifically termed as an octet.
; 210 = : The binary approximation of the kilo-, or multiplier, which causes a change of prefix. For example: = 1 kilobyte.
; 212 = : The hardware page size of an Intel x86-compatible processor.
; 215 = : The number of non-negative values for a signed 16-bit integer.
; 216 = :
; 220 = : The binary approximation of the mega-, or multiplier, which causes a change of prefix. For example: = 1 megabyte.
; 224 = :
; 230 = : The binary approximation of the giga-, or multiplier, which causes a change of prefix. For example, = 1 gigabyte.
; 231 = : The number of non-negative values for a signed 32-bit integer. Since Unix time is measured in seconds since January 1, 1970, it will run out at seconds or 03:14:07 UTC on Tuesday, 19 January 2038 on 32-bit computers running Unix, a problem known as the year 2038 problem.
; 232 = :
; 240 = : The binary approximation of the tera-, or multiplier, which causes a change of prefix. For example, bytes = 1 terabyte or tebibyte.
; 250 = : The binary approximation of the peta-, or multiplier. bytes = 1 petabyte or pebibyte.
; 253 = : The number until which all integer values can exactly be represented in IEEE double precision floating-point format. Also the first power of 2 to start with the digit 9 in decimal.
; 256 = : The number of different possible keys in the obsolete 56 bit DES symmetric cipher.
; 260 = : The binary approximation of the exa-, or multiplier. bytes = 1 exabyte or exbibyte.
; 263 = :
; 264 = :
; 268 = : The first power of 2 to contain all decimal digits.
; 270 = : The binary approximation of the zetta-, or multiplier. bytes = 1 zettabyte.
; 280 = : The binary approximation of the yotta-, or multiplier. bytes = 1 yottabyte.
; 286 = : 286 is conjectured to be the largest power of two not containing a zero in decimal.
; 296 = : The total number of IPv6 addresses generally given to a local Internet registry. In CIDR notation, ISPs are given a, which means that bits are available for addresses. Thus, 296 addresses.
; 2108 = : The largest known power of 2 not containing a 9 in decimal.
; 2126 = : The largest known power of 2 not containing a pair of consecutive equal digits.
; 2128 = : The total number of IP addresses available under IPv6, the number of distinct universally unique identifiers (UUIDs), the maximum number that can fit in a 32-bit IEEE single-precision floating-point format, and the total number of different possible keys in the AES 128-bit key space.
; 2168 = : The largest known power of 2 not containing all decimal digits.
; 2192 = : The total number of different possible keys in the AES 192-bit key space.
; 2229 = : 2229 is the largest known power of two containing the least number of zeros relative to its power. It is conjectured by Metin Sariyar that every digit 0 to 9 is inclined to appear an equal number of times in the decimal expansion of power of two as the power increases.
; 2256 = : The total number of different possible keys in the AES 256-bit key space.
; 2 = : The maximum number that can fit in a 64-bit IEEE double-precision floating-point format.
; 2 = : The maximum number that can fit in a 128-bit IEEE quadruple-precision floating-point format
; 2 = : The maximum number that can fit in a 256-bit IEEE octuple-precision floating-point format
; 2 = : One more than the largest known prime number.

Powers of two in music theory

In musical notation, all unmodified note values have a duration equal to a whole note divided by a power of two; for example a half note, a quarter note, an eighth note and a sixteenth note. Dotted or otherwise modified notes have other durations. In time signatures the lower numeral, the beat unit, which can be seen as the denominator of a fraction, is almost always a power of two.
If the ratio of frequencies of two pitches is a power of two, then the interval between those pitches is full octaves. In this case, the corresponding notes have the same name.
The mathematical coincidence, from, closely relates the interval of 7 semitones in equal temperament to a perfect fifth of just intonation:, correct to about 0.1%. The just fifth is the basis of Pythagorean tuning; the difference between twelve just fifths and seven octaves is the Pythagorean comma.

Other properties

The sum of all -choose binomial coefficients is equal to. Consider the set of all -digit binary integers. Its cardinality is. It is also the sums of the cardinalities of certain subsets: the subset of integers with no 1s, the subset with a single 1, the subset with two 1s, and so on up to the subset with 1s. Each of these is in turn equal to the binomial coefficient indexed by and the number of 1s being considered.
Currently, powers of two are the only known almost perfect numbers.
The cardinality of the power set of a set is always, where is the cardinality of.
The number of vertices of an -dimensional hypercube is. Similarly, the number of -faces of an -dimensional cross-polytope is also and the formula for the number of -faces an -dimensional cross-polytope has is
The sum of the first powers of two is given by
for being any positive integer.
Thus, the sum of the powers
can be computed simply by evaluating: .
The sum of the reciprocals of the powers of two is 1. The sum of the reciprocals of the squared powers of two is 1/3.
The smallest natural power of two whose decimal representation begins with 7 is
Every power of 2 can be written as the [Jacobi's four-square theorem|sum of four square numbers in 24 ways]. The powers of 2 are the natural numbers greater than 1 that can be written as the sum of four square numbers in the fewest ways.
As a real polynomial, an + bn is irreducible, if and only if n is a power of two.
But in the domain of complex numbers, the polynomial can always be factorized as
,
even if n is a power of two.
The only known powers of 2 with all digits even are 21 = 2, 22 = 4, 23 = 8, 26 = 64 and 211 =. The first 3 powers of 2 with all but last digit odd is 24 = 16, 25 = 32 and 29 = 512. The next such power of 2 of form 2n should have n of at least 6 digits. The only powers of 2 with all digits distinct are 20 = 1 to 215 =, 220 = and 229 =.

Negative powers of two

Huffman codes deliver optimal lossless data compression when probabilities of the source symbols are all negative powers of two.