Power of two

Last updated
Visualization of powers of two from 1 to 1024 (2 to 2 ). Powers of two cuboids.svg
Visualization of powers of two from 1 to 1024 (2 to 2 ).

A power of two is a number of the form 2n where n is an integer, that is, 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, [1] so we have 1, 2, and 2 multiplied by itself a certain number of times. [2]

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.

Computer science

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 has a kill screen at level 256.

Powers of two are often used to measure computer memory. A byte is now considered 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, typically of 5 to 32 bits, rather than only an 8-bit unit.) The prefix kilo, in conjunction with byte, may be, and has traditionally been, used, to mean 1,024 (210). However, in general, the term kilo has been used in the International System of Units to mean 1,000 (103). Binary prefixes have been standardized, such as kibi (Ki) meaning 1,024. Nearly all processor registers have sizes that are powers of two, 32 or 64 being very common.

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 not powers of two occur in a number of situations, such as video resolutions, but they are often the sum or product of only two or three powers of two, or powers of two minus one. For example, 640 = 32 × 20, and 480 = 32 × 15. Put another way, they have fairly regular bit patterns.

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 n terms of this progression is a prime number (and thus is a Mersenne prime as mentioned above), then this sum times the nth term is a perfect number. For example, the sum of the first 5 terms of the series 1 + 2 + 4 + 8 + 16 = 31, 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 p divides 496 and it is not amongst these numbers. Assume p q is equal to 16 × 31, or 31 is to q as p is to 16. Now p cannot divide 16 or it would be amongst the numbers 1, 2, 4, 8 or 16. Therefore, 31 cannot divide q. And since 31 does not divide q and q measures 496, the fundamental theorem of arithmetic implies that q must divide 16 and be amongst the numbers 1, 2, 4, 8 or 16. Let q be 4, then p must be 124, which is impossible since by hypothesis p is not amongst the numbers 1, 2, 4, 8, 16, 31, 62, 124 or 248.

Table of values

(sequence A000079 in the OEIS )

0 1 16 65,536 324,294,967,29648281,474,976,710,656
1 2 17131,072338,589,934,59249562,949,953,421,312
2 4 18262,1443417,179,869,184501,125,899,906,842,624
3 8 19524,2883534,359,738,368512,251,799,813,685,248
4 16 201,048,5763668,719,476,736524,503,599,627,370,496
5 32 212,097,15237137,438,953,472539,007,199,254,740,992
6 64 224,194,30438274,877,906,9445418,014,398,509,481,984
7 128 238,388,60839549,755,813,8885536,028,797,018,963,968
8 256 2416,777,216401,099,511,627,7765672,057,594,037,927,936
9 512 2533,554,432412,199,023,255,55257144,115,188,075,855,872
10 1,024 2667,108,864424,398,046,511,10458288,230,376,151,711,744
11 2,048 27134,217,728438,796,093,022,20859576,460,752,303,423,488
12 4,096 28268,435,4564417,592,186,044,416601,152,921,504,606,846,976
13 8,192 29536,870,9124535,184,372,088,832612,305,843,009,213,693,952

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 2k, and the period is the multiplicative order of 2 modulo 5k, which is φ(5k) = 4 × 5k1 (see Multiplicative group of integers modulo n).[ citation needed ]

Powers of 1024

(sequence A140300 in the OEIS)

The first few powers of 210 are slightly larger than those same powers of 1000:

20=1= 10000(0% deviation)
210=1 024≈ 10001(2.4% deviation)
220=1 048 576≈ 10002(4.9% deviation)
230=1 073 741 824≈ 10003(7.4% deviation)
240=1 099 511 627 776≈ 10004(10.0% deviation)
250=1 125 899 906 842 624≈ 10005(12.6% deviation)
260=1 152 921 504 606 846 976≈ 10006(15.3% deviation)
270=1 180 591 620 717 411 303 424≈ 10007(18.1% deviation)
280=1 208 925 819 614 629 174 706 176≈ 10008(20.9% deviation)
290=1 237 940 039 285 380 274 899 124 224≈ 10009(23.8% deviation)
2100=1 267 650 600 228 229 401 496 703 205 376≈ 100010(26.8% deviation)
2110=1 298 074 214 633 706 907 132 624 082 305 024≈ 100011(29.8% deviation)
2120=1 329 227 995 784 915 872 903 807 060 280 344 576≈ 100012(32.9% deviation)
2130=1 361 129 467 683 753 853 853 498 429 727 072 845 824≈ 100013(36.1% deviation)
2140=1 393 796 574 908 163 946 345 982 392 040 522 594 123 776≈ 100014(39.4% deviation)
2150=1 427 247 692 705 959 881 058 285 969 449 495 136 382 746 624≈ 100015(42.7% deviation)

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 (23), double exponentials of two are common. For example,

n2n22n(sequence A001146 in the OEIS )
01 2
12 4
24 16
38 256
416 65,536
66418,446,744,073,709,551,616 (20 digits)
7128340,282,366,920,938,463,463,374,607,431,768,211,456 (39 digits)
8256115,792,089,237,316,195,423,570,985,008,687,907,853,269,984,665,640,564,039,457,584,007,913,129,639,936 (78 digits)
951213,407,807,929,942,597,099,574,024,998,205,846,127,479,365,820,592,393,377,723,561,443,721,764,030,073,546,976,801,874,298,166,903,427,690,031,858,186,486,050,853,753,882,811,946,569,946,433,649,006,084,096 (155 digits)
101,024179,769,313,486,231,590,772,930,...,304,835,356,329,624,224,137,216 (309 digits)
112,04832,317,006,071,311,007,300,714,8...,193,555,853,611,059,596,230,656 (617 digits)
124,0961,044,388,881,413,152,506,691,75...,243,804,708,340,403,154,190,336 (1,234 digits)
138,1921,090,748,135,619,415,929,462,98...,997,186,505,665,475,715,792,896 (2,467 digits)
1416,3841,189,731,495,357,231,765,085,75...,460,447,027,290,669,964,066,816 (4,933 digits)
1532,7681,415,461,031,044,954,789,001,55...,541,122,668,104,633,712,377,856 (9,865 digits)
1665,5362,003,529,930,406,846,464,979,07...,339,445,587,895,905,719,156,736 (19,729 digits)
17131,0724,014,132,182,036,063,039,166,06...,850,665,812,318,570,934,173,696 (39,457 digits)
18262,14416,113,257,174,857,604,736,195,7...,753,862,605,349,934,298,300,416 (78,914 digits)

Several of these numbers represent the number of values representable using common computer data types. For example, a 32-bit word consisting of 4 bytes can represent 232 distinct values, which can either be regarded as mere bit-patterns, or are more commonly interpreted as the unsigned numbers from 0 to 232 − 1, or as the range of signed numbers between −231 and 231 − 1. Also see tetration and lower hyperoperations. For more about representing signed numbers see two's complement.

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. [3]

Selected powers of two

28 = 256
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 = 1,024
The binary approximation of the kilo-, or 1,000 multiplier, which causes a change of prefix. For example: 1,024  bytes = 1  kilobyte (or kibibyte).
This number has no special significance to computers, but is important to humans because we make use of powers of ten.
212 = 4,096
The hardware page size of an Intel x86-compatible processor.
215 = 32,768
The number of non-negative values for a signed 16-bit integer.
216 = 65,536
The number of distinct values representable in a single word on a 16-bit processor, such as the original x86 processors. [4]
The maximum range of a short integer variable in the C#, and Java 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 = 1,048,576
The binary approximation of the mega-, or 1,000,000 multiplier, which causes a change of prefix. For example: 1,048,576  bytes = 1  megabyte (or mibibyte).
This number has no special significance to computers, but is important to humans because we make use of powers of ten.
224 = 16,777,216
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, with 8 bits for each channel, or 24 bits in total.
The size of the largest unsigned integer or address in computers with 24-bit registers or data buses.
229 = 536,870,912
The largest power of two with distinct digits in base ten. [5]
230 = 1,073,741,824
The binary approximation of the giga-, or 1,000,000,000 multiplier, which causes a change of prefix. For example, 1,073,741,824 bytes = 1  gigabyte (or gibibyte).
This number has no special significance to computers, but is important to humans because we make use of powers of ten.
231 = 2,147,483,648
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 2,147,483,647 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 = 4,294,967,296
The number of distinct values representable in a single word on a 32-bit processor. [6] Or, the number of values representable in a doubleword on a 16-bit processor, such as the original x86 processors. [4]
The range of an int variable in the Java and C# programming languages.
The range of a Cardinal or Integer variable in the Pascal programming language.
The minimum range of a long integer variable in the C and C++ programming languages.
The total number of IP addresses under IPv4. Although this is a seemingly large number, IPv4 address exhaustion is imminent.
The number of binary operations with domain equal to any 4-element set, such as GF(4).
240 = 1,099,511,627,776
The binary approximation of the tera-, or 1,000,000,000,000 multiplier, which causes a change of prefix. For example, 1,099,511,627,776 bytes = 1 terabyte (or tebibyte).
This number has no special significance to computers, but is important to humans because we make use of powers of ten.
250 = 1,125,899,906,842,624
The binary approximation of the peta-, or 1,000,000,000,000,000 multiplier. 1,125,899,906,842,624 bytes = 1 petabyte (or pebibyte).
253 = 9,007,199,254,740,992
The number until which all integer values can exactly be represented in IEEE double precision floating-point format.
256 = 72,057,594,037,927,936
The number of different possible keys in the obsolete 56 bit DES symmetric cipher.
260 = 1,152,921,504,606,846,976
The binary approximation of the exa-, or 1,000,000,000,000,000,000 multiplier. 1,152,921,504,606,846,976 bytes = 1 exabyte (or exbibyte).
263 = 9,223,372,036,854,775,808
The number of non-negative values for a signed 64-bit integer.
264 = 18,446,744,073,709,551,616
The number of distinct values representable in a single word on a 64-bit processor. Or, the number of values representable in a doubleword on a 32-bit processor. Or, the number of values representable in a quadword on a 16-bit processor, such as the original x86 processors. [4]
The range of a long variable in the Java and C# programming languages.
The range of a Int64 or QWord variable in the Pascal programming language.
The total number of IPv6 addresses generally given to a single LAN or subnet.
One more than the number of grains of rice on a chessboard, according to the old story, where the first square contains one grain of rice and each succeeding square twice as many as the previous square. For this reason the number 264 – 1 is known as the "chess number".
264 – 1 is also the numbers of moves required to complete the legendary 64-disk version of the Tower of Hanoi.
268 = 295,147,905,179,352,825,856
The first power of 2 to contain all decimal digits. (sequence A137214 in the OEIS )
270 = 1,180,591,620,717,411,303,424
The binary approximation of the zetta-, or 1,000,000,000,000,000,000,000 multiplier. 1,180,591,620,717,411,303,424 bytes = 1 zettabyte (or zebibyte).
280 = 1,208,925,819,614,629,174,706,176
The binary approximation of the yotta-, or 1,000,000,000,000,000,000,000,000 multiplier. 1,208,925,819,614,629,174,706,176 bytes = 1 yottabyte (or yobibyte).
286 = 77,371,252,455,336,267,181,195,264
286 is conjectured to be the largest power of two not containing a zero in decimal. [7]
296 = 79,228,162,514,264,337,593,543,950,336
The total number of IPv6 addresses generally given to a local Internet registry. In CIDR notation, ISPs are given a /32, which means that 128-32=96 bits are available for addresses (as opposed to network designation). Thus, 296 addresses.
2128 = 340,282,366,920,938,463,463,374,607,431,768,211,456
The total number of IP addresses available under IPv6. Also the number of distinct universally unique identifiers (UUIDs).
2168 = 374,144,419,156,711,147,060,143,317,175,368,453,031,918,731,001,856
The largest known power of 2 not containing all decimal digits (the digit 2 is missing in this case). (sequence A137214 in the OEIS )
2192 = 6,277,101,735,386,680,763,835,789,423,207,666,416,102,355,444,464,034,512,896
The total number of different possible keys in the AES 192-bit key space (symmetric cipher).
2256 =
The total number of different possible keys in the AES 256-bit key space (symmetric cipher).
2333 =
The smallest power of 2 greater than a googol (10100).
21024 = 179,769,313,486,231,590,772,931,...,304,835,356,329,624,224,137,216
The maximum number that can fit in an IEEE double-precision floating-point format, and hence the maximum number that can be represented by many programs, for example Microsoft Excel.
282,589,933 = 148,894,445,742,041,...,210,325,217,902,592
One more than the largest known prime number as of December 2018. It has more than 24 million digits. [8]

Other properties

The sum of all n-choose binomial coefficients is equal to 2n. Consider the set of all n-digit binary integers. Its cardinality is 2n. It is also the sums of the cardinalities of certain subsets: the subset of integers with no 1s (consisting of a single number, written as n 0s), the subset with a single 1, the subset with two 1s, and so on up to the subset with n 1s (consisting of the number written as n 1s). Each of these is in turn equal to the binomial coefficient indexed by n and the number of 1s being considered (for example, there are 10-choose-3 binary numbers with ten digits that include exactly three 1s).

Currently, powers of two are the only known almost perfect numbers.

The number of vertices of an n-dimensional hypercube is 2n. Similarly, the number of (n − 1)-faces of an n-dimensional cross-polytope is also 2n and the formula for the number of x-faces an n-dimensional cross-polytope has is

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 [9]

Every power of 2 (excluding 1) can be written as the 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 least number of ways.

See also

Related Research Articles

Binary-coded decimal class of binary encodings of decimal numbers where each decimal digit is represented by a fixed number of bits, usually four or eight. Special bit patterns are sometimes used for a sign or for other indications

In computing and electronic systems, binary-coded decimal (BCD) is a class of binary encodings of decimal numbers where each digit is represented by a fixed number of bits, usually four or eight. Sometimes, special bit patterns are used for a sign or other indications.

Floating-point arithmetic Computer format for representing real numbers

In computing, floating-point arithmetic (FP) is arithmetic using formulaic representation of real numbers as an approximation to support a trade-off between range and precision. For this reason, floating-point computation is often found in systems which include very small and very large real numbers, which require fast processing times. A number is, in general, represented approximately to a fixed number of significant digits and scaled using an exponent in some fixed base; the base for the scaling is normally two, ten, or sixteen. A number that can be represented exactly is of the following form:

Hexadecimal Base 16 numerical system

In mathematics and computing, hexadecimal is a positional system that represents numbers using a base of 16. Unlike the common way of representing numbers with ten symbols, it uses sixteen distinct symbols, most often the symbols "0"–"9" to represent values zero to nine, and "A"–"F" to represent values ten to fifteen.

In computer science, an integer is a datum of integral data type, a data type that represents some range of mathematical integers. Integral data types may be of different sizes and may or may not be allowed to contain negative values. Integers are commonly represented in a computer as a group of binary digits (bits). The size of the grouping varies so the set of integer sizes available varies between different types of computers. Computer hardware, including virtual machines, nearly always provide a way to represent a processor register or memory address as an integer.

Octal Base-8 positional notation, using digits 0–7

The octal numeral system, or oct for short, is the base-8 number system, and uses the digits 0 to 7. Octal numerals can be made from binary numerals by grouping consecutive binary digits into groups of three. For example, the binary representation for decimal 74 is 1001010. Two zeroes can be added at the left: (00)1 001 010, corresponding the octal digits 1 1 2, yielding the octal representation 112.

A computer number format is the internal representation of numeric values in digital computer and calculator hardware and software. Normally, numeric values are stored as groupings of bits, named for the number of bits that compose them. The encoding between numerical values and bit patterns is chosen for convenience of the operation of the computer; the bit format used by the computer's instruction set generally requires conversion for external use such as printing and display. Different types of processors may have different internal representations of numerical values. Different conventions are used for integer and real numbers. Most calculations are carried out with number formats that fit into a processor register, but some software systems allow representation of arbitrarily large numbers using multiple words of memory.

A multiplication algorithm is an algorithm to multiply two numbers. Depending on the size of the numbers, different algorithms are used. Efficient multiplication algorithms have existed since the advent of the decimal system.

Binary number Number expressed though the symbols 0 and 1

In mathematics and digital electronics, a binary number is a number expressed in the base-2 numeral system or binary numeral system, which uses only two symbols: typically "0" (zero) and "1" (one).

In computer programming, a bitwise operation operates on one or more bit patterns or binary numerals at the level of their individual bits. It is a fast and simple action, directly supported by the processor, and is used to manipulate values for comparisons and calculations.

Two's complement is a mathematical operation on binary numbers, and is an example of a radix complement. It is used in computing as a method of signed number representation.

In computing, a fixed-point number representation is a real data type for a number that has a fixed number of digits after the radix point. Fixed-point number representation can be compared to the more complicated floating-point number representation.

In computing, signed number representations are required to encode negative numbers in binary number systems.

In computer science, arbitrary-precision arithmetic, also called bignum arithmetic, multiple-precision arithmetic, or sometimes infinite-precision arithmetic, indicates that calculations are performed on numbers whose digits of precision are limited only by the available memory of the host system. This contrasts with the faster fixed-precision arithmetic found in most arithmetic logic unit (ALU) hardware, which typically offers between 8 and 64 bits of precision.

Schönhage–Strassen algorithm

The Schönhage–Strassen algorithm is an asymptotically fast multiplication algorithm for large integers. It was developed by Arnold Schönhage and Volker Strassen in 1971. The run-time bit complexity is, in Big O notation, for two n-digit numbers. The algorithm uses recursive Fast Fourier transforms in rings with 2n+1 elements, a specific type of number theoretic transform.

Methods of computing square roots are numerical analysis algorithms for finding the principal, or non-negative, square root of a real number. Arithmetically, it means given S, a procedure for finding a number which when multiplied by itself, yields S; algebraically, it means a procedure for finding the non-negative root of the equation x2 - S = 0; geometrically, it means given the area of a square, a procedure for constructing a side of the square.

Quote notation is a representation of the rational numbers based on Kurt Hensel's p-adic numbers. In quote notation, arithmetic operations take particularly simple, consistent forms, producing exact answers with no roundoff error. Quote notation’s arithmetic algorithms work in a right-to-left direction; addition, subtraction, and multiplication algorithms are the same as for natural numbers, and division is easier than the usual division algorithm. The notation was invented by Eric Hehner of the University of Toronto and Nigel Horspool, then at McGill University, and published in the SIAM Journal on Computing, v.8, n.2, May 1979, pp. 124–134.

65536 is the natural number following 65535 and preceding 65537.

In computing, bit numbering is the convention used to identify the bit positions in a binary number or a container of such a value. The bit number starts with zero and is incremented by one for each subsequent bit position.

Single-precision floating-point format is a computer number format, usually occupying 32 bits in computer memory; it represents a wide dynamic range of numeric values by using a floating radix point.

Moser–de Bruijn sequence

In number theory, the Moser–de Bruijn sequence is an integer sequence named after Leo Moser and Nicolaas Govert de Bruijn, consisting of the sums of distinct powers of 4. It begins


  1. Lipschutz, Seymour (1982). Schaum's Outline of Theory and Problems of Essential Computer Mathematics. New York: McGraw-Hill. p. 3. ISBN   0-07-037990-4.
  2. Sewell, Michael J. (1997). Mathematics Masterclasses. Oxford: Oxford University Press. p.  78. ISBN   0-19-851494-8.
  3. Guy, Richard K. (2004), "E24 Irrationality sequences", Unsolved problems in number theory (3rd ed.), Springer-Verlag, p. 346, ISBN   0-387-20860-7, Zbl   1058.11001, archived from the original on 2016-04-28
  4. 1 2 3 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
  5. Prime Curios!: 536870912 "Archived copy". Archived from the original on 2017-09-05. Retrieved 2017-09-05.CS1 maint: archived copy as title (link)
  6. Powers of 2 by Vaughn Aubuchon Archived 2015-08-12 at the Wayback Machine
  7. Weisstein, Eric W. "Zero." From MathWorld--A Wolfram Web Resource. "Archived copy". Archived from the original on 2013-06-01. Retrieved 2013-05-29.CS1 maint: archived copy as title (link)
  8. https://www.mersenne.org/primes/?press=M82589933
  9. Paweł Strzelecki (1994). "O potęgach dwójki (About powers of two)" (in Polish). Delta. Archived from the original on 2016-05-09.