Power of two explained

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.

Powers of two with non-negative exponents are integers:,, and is two multiplied by itself times.[1] [2] 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 a negative integer, is one half multiplied by itself times. Thus the first few powers of two where is negative 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 exponent of, written as, is the number of ways the bits in a binary word of length can be arranged. A word, interpreted as an unsigned integer, can represent values from 0  to   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 . 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,, and . 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 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 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 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.

Table of values

011665,536324,294,967,29648281,474,976,710,656
1 217 131,07233 8,589,934,59249 562,949,953,421,312
2 418 262,14434 17,179,869,18450 1,125,899,906,842,624
3 819 524,28835 34,359,738,36851 2,251,799,813,685,248
416201,048,5763668,719,476,736524,503,599,627,370,496
5 3221 2,097,15237 137,438,953,47253 9,007,199,254,740,992
6 6422 4,194,30438 274,877,906,94454 18,014,398,509,481,984
7 12823 8,388,60839 549,755,813,88855 36,028,797,018,963,968
82562416,777,216401,099,511,627,7765672,057,594,037,927,936
9 51225 33,554,43241 2,199,023,255,55257 144,115,188,075,855,872
10 1,02426 67,108,86442 4,398,046,511,10458 288,230,376,151,711,744
11 2,04827 134,217,72843 8,796,093,022,20859 576,460,752,303,423,488
12 4,09628 268,435,45644 17,592,186,044,41660 1,152,921,504,606,846,976
13 8,19229 536,870,91245 35,184,372,088,83261 2,305,843,009,213,693,952
14 16,38430 1,073,741,82446 70,368,744,177,66462 4,611,686,018,427,387,904
15 32,76831 2,147,483,64847 140,737,488,355,32863 9,223,372,036,854,775,808

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 1000 (103). The powers of 210 values that have less than 27% deviation are listed below:

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)
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.[3] 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. The first 20 of them are:

digits
0 1 1
1 2 1
2 4 2
3 8 3
4 16 5
5 32 4,294,967,296 10
6 64 20
7 128 39
8 256 78
9 512 155
10 1,024 309
11 2,048 617
12 4,096 1,234
13 8,192 2,467
14 16,384 4,933
15 32,768 9,865
1665,53619,729
17131,07239,457
18262,14478,914
19524,288157,827
Also see Fermat number, tetration and lower hyperoperations.

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

All of these numbers end in 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 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).

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

2n
2
form an irrationality sequence: for every sequence

xi

of positive integers, the series
infty
\sum
i=0
1
2i
2xi

=

1+
2x0
1+
4x1
1
16x2

+ …

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 = 4
  • The number that is the square of two. Also the first power of two tetration 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).
    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

    See main article: 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#, 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 = 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 mebibyte).
    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, 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, 16,777,216, 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 size of the largest unsigned integer or address in computers with 24-bit registers or data buses.
    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).
    231 = 2,147,483,648

    See also: 2,147,483,647.

    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

    See also: 4,294,967,295.

    The number of distinct values representable in a single word on a 32-bit processor.[5] 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 [[integer (computer science)|int]] variable in the Java, C#, and SQL 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, the number of available 32-bit IPv4 addresses has been exhausted (but not for IPv6 addresses).

    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.
    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. Also the first power of 2 to start with the digit 9 in decimal.
    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.
  • 263 − 1, a common maximum value (equivalently the number of positive values) for a signed 64-bit integer in programming languages.
    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.
  • 264 − 1, 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 is sometimes known as the "chess number".
  • 264 − 1 is also the number 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.
    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.[6]
    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, which means that 128-32=96 bits are available for addresses (as opposed to network designation). 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. Also the number of distinct universally unique identifiers (UUIDs).
    2168 =
  • The largest known power of 2 not containing all decimal digits (the digit 2 is missing in this case).
    2192 =
  • The total number of different possible keys in the AES 192-bit key space (symmetric cipher).
    2229 = 862,718,293,348,820,473,429,344,482,784,628,181,556,388,621,521,298,319,395,315,527,974,912
  • 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 (symmetric cipher).
    21,024 = 1.79
  • The maximum number that can fit in a 64-bit IEEE double-precision floating-point format (hence the maximum number that can be represented by many programs, for example Microsoft Excel).
    216,384 = 1.19
  • The maximum number that can fit in a 128-bit IEEE quadruple-precision floating-point format
    2262,144 = 1.61
  • The maximum number that can fit in a 256-bit IEEE octuple-precision floating-point format
    282,589,933 = 1.49
  • One more than the largest known prime number . [7]

    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 (1/2), a quarter note (1/4), an eighth note (1/8) and a sixteenth note (1/16). 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.

    27(\tfrac{3}{2})12

    , from
    log3
    log2

    =1.5849\ldots

    19
    12
    , closely relates the interval of 7 semitones in equal temperament to a perfect fifth of just intonation:

    27/123/2

    , 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.[8]

    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 (consisting of a single number, written as 0s), the subset with a single 1, the subset with two 1s, and so on up to the subset with 1s (consisting of the number written as 1s). Each of these is in turn equal to the binomial coefficient indexed by 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 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

    2x\tbinom{n}{x}.

    The sum of the first

    n

    powers of two (starting from

    1=20

    ) is given by,
    n-1
    \sum
    k=0

    2k=20+21+22++2n-1=2n-1

    for

    n

    being any positive integer.

    Thus, the sum of the powers

    1+21+22++263

    can be computed simply by evaluating:

    264-1

    (which is the "chess number").

    The sum of the reciprocals of the powers of two is 1. The sum of the reciprocals of the squared powers of two (powers of four) is 1/3.

    The smallest natural power of two whose decimal representation begins with 7 is[9]

    246=70 368 744 177 664.

    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 fewest ways.

    As a real polynomial, an + bn is irreducible, if and only if n is a power of two. (If n is odd, then an + bn is divisible by a+b, and if n is even but not a power of 2, then n can be written as n=mp, where m is odd, and thus

    an+bn=(ap)m+(bp)m

    , which is divisible by ap + bp.)But in the domain of complex numbers, the polynomial

    a2n+b2n

    (where n>=1) can always be factorized as

    a2n+b2n=(an+bni)(an-bni)

    , even if n is a power of two.

    Negative powers of two

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

    See also

    Notes and References

    1. Book: Lipschutz, Seymour . Schaum's Outline of Theory and Problems of Essential Computer Mathematics . 1982 . 0-07-037990-4 . 3 . McGraw-Hill . New York.
    2. Book: Sewell, Michael J. . Mathematics Masterclasses . 1997 . 0-19-851494-8 . 78 . Oxford University Press . Oxford .
    3. log1024/10001.517.1,

      log1024/1000229.2.

    4. 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. Web site: Powers of 2 Table - - - - - - Vaughn's Summaries. https://web.archive.org/web/20150812072147/http://www.vaughns-1-pagers.com/computer/powers-of-2.htm. dead. August 12, 2015. www.vaughns-1-pagers.com.
    6. Weisstein, Eric W. "Zero." From MathWorld--A Wolfram Web Resource. Web site: Zero . 2013-05-29 . live . https://web.archive.org/web/20130601190920/http://mathworld.wolfram.com/Zero.html . 2013-06-01 .
    7. Web site: Mersenne Prime Discovery - 2^82589933-1 is Prime!. www.mersenne.org.
    8. Book: Number theory in science and communication . Manfred Robert Schroeder . Springer . 2nd . 2008 . 978-3-540-85297-1 . 26–28 .
    9. Web site: O potęgach dwójki (About powers of two) . Paweł Strzelecki . pl . 1994 . Delta . live . https://web.archive.org/web/20160509191813/http://www.deltami.edu.pl/temat/matematyka/teoria_liczb/2011/03/07/O_potegach_dwojki/ . 2016-05-09.
    10. https://www.sciencedirect.com/topics/mathematics/huffman-code Huffman coding