A power of two is a number of the form where is an integer, that is, the result of exponentiation with the 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 n 2s multiplied together. The first ten powers of 2 for non-negative values of are: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, ...
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.
Computer science
Most computers use a binary (base two) representation of numbers, a number system in which each place represents a power of 2, and the only possible binary digits ("bits") are 0 and 1. Powers of two are thus ubiquitous in computing and computer science. Written in binary, a power of two always has the form 100...000 or 0.00...001, like a power of 10 in the decimal (base ten) system. Just as a decimal number can be multiplied by a power of ten by adding zeros or moving the decimal point, a binary number can be multiplied by a power of two using bit shifting (moving all of the bits a certain number of places to the left or right), one of the fastest available arithmetical operations.
Two to the th power is the number of values in which the bits in a binary word of length can be set. 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.
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 (the currency of the game) 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 (an octet), resulting in the possibility of 256 values (28). (The term byte once meant (and in some cases, still means) a collection of bits that was defined by the hardware context, typically of 5 to 32 bits, rather than only an 8-bit unit.) The prefix kilo, in conjunction with byte, has been used by computer scientists to mean (210). However, in general, the term kilo has been used in the International System of Units to mean (103). A series of binary prefixes has been standardized, including kibi (Ki) 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 (25). Similarly, a prime number (like 257) 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, ... (or, in the binary numeral system, 1, 10, 100, 1000, 10000, 100000, ... ) 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 (and thus is a Mersenne prime as mentioned above), 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 (the 5th term in the series) 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. (This is a restatement of our formula for geometric series from above.) Applying this to the geometric progression 31, 62, 124, 248, 496 (which results from 1, 2, 4, 8, 16 by multiplying all terms by 31), 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
+ 0163248 1 17 33 49 2 18 34 50 3 19 35 51 420 36 52 5 21 37 53 6 22 38 54 7 23 39 55 824 40 56 9 25 41 57 10 26 42 58 11 27 43 59 12 28 44 60 13 29 45 61 14 30 46 62 15 31 47 63
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 (see Multiplicative group of integers modulo n).
Powers of 1024
The first few powers of 210 are slightly larger than those same powers of (103). The first 11 powers of 210 values are listed below: +20=1= 10000(0% deviation)210=≈ 10001(2.4% deviation)220=≈ 10002(4.9% deviation)230=≈ 10003(7.4% deviation)240=≈ 10004(10.0% deviation)250=≈ 10005(12.6% deviation)260=≈ 10006(15.3% deviation)270=≈ 10007(18.1% deviation)280=≈ 10008(20.9% deviation)290=≈ 10009(23.8% deviation)2100=≈ 100010(26.8% deviation) 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 (specifically integers) 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 0 1 2 1 1 2 4 1 2 4 16 2 3 8 256 3 4 16 5 5 32 6 64 7 128 8 256 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 (see Multiplicative group of integers modulo n).
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. (The term byte is often defined as a collection of bits rather than the strict definition of an 8-bit quantity, as demonstrated by the term kilobyte.) 210 = The binary approximation of the kilo-, or multiplier, which causes a change of prefix. For example: = 1 kilobyte (or kibibyte). 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 =
The number of distinct values representable in a single word on a 16-bit processor, such as the original x86 processors.Though they vary in word size, all x86 processors use the term "word" to mean 16 bits; thus, a 32-bit x86 processor refers to its native wordsize as a dword The maximum range of a short integer variable in the C#, Java, and SQL programming languages. The maximum range of a Word or Smallint variable in the Pascal programming language. The number of binary relations on a 4-element set. 220 = The binary approximation of the mega-, or multiplier, which causes a change of prefix. For example: = 1 megabyte (or mebibyte). 224 = The number of unique colors that can be displayed in truecolor, which is used by common computer monitors. This number is the result of using the three-channel RGB system, where colors are defined by three values (red, green and blue) independently ranging from 0 (00) to 255 (FF) inclusive. This gives 8 bits for each channel, or 24 bits in total; for example, pure black is #000000, pure white is #FFFFFF. The space of all possible colors, , can be determined by 166 (6 digits with 16 possible values for each), 2563 (3 channels with 256 possible values for each), or 224 (24 bits with 2 possible values for each). The number until which all integer values can exactly be represented in IEEE single precision floating-point format. The size of the largest unsigned integer or address in computers with 24-bit registers or data buses. 230 = The binary approximation of the giga-, or multiplier, which causes a change of prefix. For example, = 1 gigabyte (or gibibyte). 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 =