Power of two
In mathematics, a power of two means a number of the form 2^{n} 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,^{[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.
Expressions and notations
Verbal expressions, mathematical notations, and computer programming expressions using a power operator or function include:
- 2 to the n
- 2 to the power of n
- 2 power n
- power(2, n)
- pow(2, n)
- 2^{n}
- 1 << n
- 2 ^ n
- 2 ** n
- 2 [3] n
- 2 ↑ n
- A(n - 3, 3) + 3
Computer science
Two to the power of n, written as 2^{n}, 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…000_{2}) to 2^{n} − 1 (111…111_{2}) 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 2^{8} − 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.
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 (2^{8}). (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 (2^{10}). However, in general, the term kilo has been used in the International System of Units to mean 1,000 (10^{3}). 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 most 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 = 512 + 128 = 128 × 5, and 480 = 32 × 15. Put another way, they have fairly regular bit patterns.
Mersenne 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 (2^{5}). 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 (means, a Mersenne prime 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.
The first 96 powers of two
(sequence A000079 in the OEIS)
2^{0} | = | 1 | 2^{16} | = | 65,536 | 2^{32} | = | 4,294,967,296 | 2^{48} | = | 281,474,976,710,656 | 2^{64} | = | 18,446,744,073,709,551,616 | 2^{80} | = | 1,208,925,819,614,629,174,706,176 | |||||
2^{1} | = | 2 | 2^{17} | = | 131,072 | 2^{33} | = | 8,589,934,592 | 2^{49} | = | 562,949,953,421,312 | 2^{65} | = | 36,893,488,147,419,103,232 | 2^{81} | = | 2,417,851,639,229,258,349,412,352 | |||||
2^{2} | = | 4 | 2^{18} | = | 262,144 | 2^{34} | = | 17,179,869,184 | 2^{50} | = | 1,125,899,906,842,624 | 2^{66} | = | 73,786,976,294,838,206,464 | 2^{82} | = | 4,835,703,278,458,516,698,824,704 | |||||
2^{3} | = | 8 | 2^{19} | = | 524,288 | 2^{35} | = | 34,359,738,368 | 2^{51} | = | 2,251,799,813,685,248 | 2^{67} | = | 147,573,952,589,676,412,928 | 2^{83} | = | 9,671,406,556,917,033,397,649,408 | |||||
2^{4} | = | 16 | 2^{20} | = | 1,048,576 | 2^{36} | = | 68,719,476,736 | 2^{52} | = | 4,503,599,627,370,496 | 2^{68} | = | 295,147,905,179,352,825,856 | 2^{84} | = | 19,342,813,113,834,066,795,298,816 | |||||
2^{5} | = | 32 | 2^{21} | = | 2,097,152 | 2^{37} | = | 137,438,953,472 | 2^{53} | = | 9,007,199,254,740,992 | 2^{69} | = | 590,295,810,358,705,651,712 | 2^{85} | = | 38,685,626,227,668,133,590,597,632 | |||||
2^{6} | = | 64 | 2^{22} | = | 4,194,304 | 2^{38} | = | 274,877,906,944 | 2^{54} | = | 18,014,398,509,481,984 | 2^{70} | = | 1,180,591,620,717,411,303,424 | 2^{86} | = | 77,371,252,455,336,267,181,195,264 | |||||
2^{7} | = | 128 | 2^{23} | = | 8,388,608 | 2^{39} | = | 549,755,813,888 | 2^{55} | = | 36,028,797,018,963,968 | 2^{71} | = | 2,361,183,241,434,822,606,848 | 2^{87} | = | 154,742,504,910,672,534,362,390,528 | |||||
2^{8} | = | 256 | 2^{24} | = | 16,777,216 | 2^{40} | = | 1,099,511,627,776 | 2^{56} | = | 72,057,594,037,927,936 | 2^{72} | = | 4,722,366,482,869,645,213,696 | 2^{88} | = | 309,485,009,821,345,068,724,781,056 | |||||
2^{9} | = | 512 | 2^{25} | = | 33,554,432 | 2^{41} | = | 2,199,023,255,552 | 2^{57} | = | 144,115,188,075,855,872 | 2^{73} | = | 9,444,732,965,739,290,427,392 | 2^{89} | = | 618,970,019,642,690,137,449,562,112 | |||||
2^{10} | = | 1,024 | 2^{26} | = | 67,108,864 | 2^{42} | = | 4,398,046,511,104 | 2^{58} | = | 288,230,376,151,711,744 | 2^{74} | = | 18,889,465,931,478,580,854,784 | 2^{90} | = | 1,237,940,039,285,380,274,899,124,224 | |||||
2^{11} | = | 2,048 | 2^{27} | = | 134,217,728 | 2^{43} | = | 8,796,093,022,208 | 2^{59} | = | 576,460,752,303,423,488 | 2^{75} | = | 37,778,931,862,957,161,709,568 | 2^{91} | = | 2,475,880,078,570,760,549,798,248,448 | |||||
2^{12} | = | 4,096 | 2^{28} | = | 268,435,456 | 2^{44} | = | 17,592,186,044,416 | 2^{60} | = | 1,152,921,504,606,846,976 | 2^{76} | = | 75,557,863,725,914,323,419,136 | 2^{92} | = | 4,951,760,157,141,521,099,596,496,896 | |||||
2^{13} | = | 8,192 | 2^{29} | = | 536,870,912 | 2^{45} | = | 35,184,372,088,832 | 2^{61} | = | 2,305,843,009,213,693,952 | 2^{77} | = | 151,115,727,451,828,646,838,272 | 2^{93} | = | 9,903,520,314,283,042,199,192,993,792 | |||||
2^{14} | = | 16,384 | 2^{30} | = | 1,073,741,824 | 2^{46} | = | 70,368,744,177,664 | 2^{62} | = | 4,611,686,018,427,387,904 | 2^{78} | = | 302,231,454,903,657,293,676,544 | 2^{94} | = | 19,807,040,628,566,084,398,385,987,584 | |||||
2^{15} | = | 32,768 | 2^{31} | = | 2,147,483,648 | 2^{47} | = | 140,737,488,355,328 | 2^{63} | = | 9,223,372,036,854,775,808 | 2^{79} | = | 604,462,909,807,314,587,353,088 | 2^{95} | = | 39,614,081,257,132,168,796,771,975,168 |
One can see that 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, of course, where each pattern has starting point 2^{k}, and the period is the multiplicative order of 2 modulo 5^{k}, which is φ(5^{k}) = 4 × 5^{k−1} (see Multiplicative group of integers modulo n).
Powers of 1024
(sequence A140300 in the OEIS)
The first few powers of 2^{10} are a little more than those of 1000:
2^{0} | = | 1 | = 1000^{0} | (0% deviation) |
2^{10} | = | 1 024 | ≈ 1000^{1} | (2.4% deviation) |
2^{20} | = | 1 048 576 | ≈ 1000^{2} | (4.9% deviation) |
2^{30} | = | 1 073 741 824 | ≈ 1000^{3} | (7.4% deviation) |
2^{40} | = | 1 099 511 627 776 | ≈ 1000^{4} | (10% deviation) |
2^{50} | = | 1 125 899 906 842 624 | ≈ 1000^{5} | (12.6% deviation) |
2^{60} | = | 1 152 921 504 606 846 976 | ≈ 1000^{6} | (15.3% deviation) |
2^{70} | = | 1 180 591 620 717 411 303 424 | ≈ 1000^{7} | (18.1% deviation) |
2^{80} | = | 1 208 925 819 614 629 174 706 176 | ≈ 1000^{8} | (20.9% deviation) |
2^{90} | = | 1 237 940 039 285 380 274 899 124 224 | ≈ 1000^{9} | (23.8% deviation) |
2^{100} | = | 1 267 650 600 228 229 401 496 703 205 376 | ≈ 1000^{10} | (26.8% deviation) |
2^{110} | = | 1 298 074 214 633 706 907 132 624 082 305 024 | ≈ 1000^{11} | (29.8% deviation) |
2^{120} | = | 1 329 227 995 784 915 872 903 807 060 280 344 576 | ≈ 1000^{12} | (32.9% deviation) |
See also 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 (2^{3}), double exponentials of two are common. For example,
(sequence A001146 in the OEIS)
- 2^{1} = 2
- 2^{2} = 4
- 2^{4} = 16
- 2^{8} = 256
- 2^{16} = 65,536
- 2^{32} = 4,294,967,296
- 2^{64} = 18,446,744,073,709,551,616 (20 digits)
- 2^{128} = 340,282,366,920,938,463,463,374,607,431,768,211,456 (39 digits)
- 2^{256} =
115,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) - 2^{512} =
13,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) - 2^{1,024} = 179,769,313,486,231,590,772,931,...,304,835,356,329,624,224,137,216 (309 digits)
- 2^{2,048} = 323,170,060,713,110,073,007,148,...,193,555,853,611,059,596,230,656 (617 digits)
- 2^{4,096} = 104,438,888,141,315,250,669,175,...,243,804,708,340,403,154,190,336 (1,234 digits)
- 2^{8,192} = 109,074,813,561,941,592,946,298,...,997,186,505,665,475,715,792,896 (2,467 digits)
- 2^{16,384} = 118,973,149,535,723,176,508,576,...,460,447,027,290,669,964,066,816 (4,933 digits)
- 2^{32,768} = 141,546,103,104,495,478,900,155,...,541,122,668,104,633,712,377,856 (9,865 digits)
- 2^{65,536} = 200,352,993,040,684,646,497,907,...,339,445,587,895,905,719,156,736 (19,729 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 2^{32} distinct values, which can either be regarded as mere bit-patterns, or are more commonly interpreted as the unsigned numbers from 0 to 2^{32} − 1, or as the range of signed numbers between −2^{31} and 2^{31} − 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]}
Some selected powers of two
- 2^{8} = 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.)
- 2^{10} = 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.
- 2^{12} = 4,096
- The hardware page size of Intel x86 processor.
- 2^{16} = 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.
- 2^{20} = 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.
- 2^{24} = 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.
- 2^{30} = 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.
- 2^{31} = 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.
- 2^{32} = 4,294,967,296
- 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
int
variable in the Java and C# programming languages. - The range of a
Cardinal
orInteger
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).
- 2^{40} = 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.
- 2^{50} = 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).
- 2^{60} = 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).
- 2^{64} = 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 2^{64} – 1 is known as the "chess number".
- 2^{64} – 1 is also the numbers of moves required to complete the legendary 64-disk version of the Tower of Hanoi.
- 2^{70} = 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).
- 2^{80} = 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).
- 2^{86} = 77,371,252,455,336,267,181,195,264
- 2^{86} is conjectured to be the largest power of two not containing a zero.^{[6]}
- 2^{96} = 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, 2^{96} addresses.
- 2^{128} = 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).
- 2^{333} =
17,498,005,798,264,095,394,980,017,816,940,970,922,825,355,447,145,699,491,406,164,851,279,623,
993,595,007,385,788,105,416,184,430,592 - The smallest power of 2 greater than a googol (10^{100}).
- 2^{1024} = 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.
- 2^{74,207,281} = 300,376,418,084,606,182,052,986,...,498,687,010,073,391,086,436,352
- One more than the largest known prime number as of 2016. It has more than 22 million digits.^{[7]}
Fast algorithm to check if a positive number is a power of two
The binary representation of integers makes it possible to apply a very fast test to determine whether a given positive integer x is a power of two:
- positive x is a power of two ⇔ (x & (x − 1)) is equal to zero.
where & is a bitwise logical AND operator. Note that if x is 0, this incorrectly indicates that 0 is a power of two, so this check only works if x > 0.
Examples:
1…111…1 | 1…111…111…1 | |||||
0…010…0 | 0…010…010…0 | |||||
0…001…1 | 0…010…001…1 | |||||
0…000…0 | 0…010…000…0 |
Proof of Concept:
Proof uses the technique of contrapositive.
Statement, S: If x&(x-1) = 0 and x is an integer greater than zero then x = 2^{k} (where k is an integer such that k>=0).
Concept of Contrapositive:
S1: P -> Q is same as S2: ~Q -> ~P
In above statement S1 and S2 both are contrapositive of each other.
So statement S can be re-stated as below
S': If x is a positive integer and x ≠ 2^{k} (k is some non negative integer)then x&(x-1) ≠ 0
Proof:
If x ≠ 2^{k} then at least two bits of x are set.(Let's assume m bits are set.)
Now, bit pattern of x - 1 can be obtained by inverting all the bits of x up to first set bit of x (starting from LSB and moving towards MSB, this set bit inclusive).
Now, we observe that expression x & (x-1) has all the bits zero up to the first set bit of x and since x & (x-1) has remaining bits same as x and x has at least two set bits hence predicate x & (x-1) ≠ 0 is true.
Fast algorithm to find a number modulo a power of two
As a generalization of the above, the binary representation of integers makes it possible to calculate the modulos of a non-negative integer (x) with a power of two (y) very quickly:
- x mod y = (x & (y − 1)).
where & is a bitwise logical AND operator. This bypasses the need to perform an expensive division. This is useful if the modulo operation is a significant part of the performance critical path as this can be much faster than the regular modulo operator.
Algorithm to find a power of two nearest to a number
The following formula finds the nearest power of two, on a logarithmic scale, of a given value x > 0:
This should be distinguished from the nearest power of two on a linear scale. For example, 23 is nearer to 16 than it is to 32, but the previous formula rounds it to 32, corresponding to the fact that 23/16 = 1.4375, larger than 32/23 = 1.3913.
If x is an integer value, following steps can be taken to find the nearest value (with respect to actual value rather than the binary logarithm) in a computer program:
- Find the most significant bit position k, that is set (1) from the binary representation of x, when {{{1}}} means the least significant bit
- Then, if bit k − 1 is zero, the result is 2^{k}. Otherwise the result is 2^{k + 1}.
Algorithm to find a power of two greater than or equal to a number
Sometimes it is desired to find the least power of two that is not less than a particular integer, n. The pseudocode for an algorithm to compute the next-higher power of two is as follows. If the input is a power of two it is returned unchanged.^{[8]}
n = n - 1;
n = n | (n >> 1);
n = n | (n >> 2);
n = n | (n >> 4);
n = n | (n >> 8);
n = n | (n >> 16);
...
n = n | (n >> (bitspace / 2));
n = n + 1;
Where | is a binary or operator, >> is the binary right-shift operator, and bitspace is the size (in bits) of the integer space represented by n. For most computer architectures, this value is either 8, 16, 32, or 64. This operator works by setting all bits on the right-hand side of the most significant flagged bit to 1, and then incrementing the entire value at the end so it "rolls over" to the nearest power of two. An example of each step of this algorithm for the number 2689 is as follows:
Binary representation | Decimal representation |
---|---|
0101010000001 | 2,689 |
0101010000000 | 2,688 |
0111111000000 | 4,032 |
0111111110000 | 4,080 |
0111111111111 | 4,095 |
1000000000000 | 4,096 |
As demonstrated above, the algorithm yields the correct value of 4,096. The nearest power to 2,689 happens to be 2,048; however, this algorithm is designed only to give the next highest power of two to a given number, not the nearest.
Another way of obtaining the 'next highest' power of two to a given number independent of the length of the bitspace is as follows.
unsigned int get_nextpowerof2(unsigned int n)
{
/*
* Below indicates passed no is a power of 2, so return the same.
*/
if (!(n & (n-1))) {
return (n);
}
while (n & (n-1)) {
n = n & (n-1);
}
n = n << 1;
return n;
}
Fast algorithms to round any integer to a multiple of a given power of two
For any integer, x and integral power of two, y, if z = y - 1,
- x AND (NOT z) round down,
- (x + z) AND (NOT z) rounds up, and
- (x + y / 2) AND (NOT z) rounds to the nearest (positive values exactly halfway are rounded up whereas negative values exactly halfway are rounded down)
x to a multiple of y.
Other properties
The sum of all n-choose binomial coefficients is equal to 2^{n}. Consider the set of all n-digit binary integers. Its cardinality is 2^{n}. 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 (e.g., there are 10-choose-3 binary numbers with ten digits that include exactly three 1s).
The number of vertices of an n-dimensional hypercube is 2^{n}. Similarly, the number of (n − 1)-faces of an n-dimensional cross-polytope is also 2^{n} 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 2. 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]}
See also
- Binary number
- Geometric progression
- Gould's sequence
- Integer binary logarithm
- Inchworm Song
- Octave (electronics)
- Sum-free sequence
References
- ↑ 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.
- ↑ Sewell, Michael J. (1997). Mathematics Masterclasses. Oxford: Oxford University Press. p. 78. ISBN 0-19-851494-8.
- ↑ 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.
- 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
- ↑ Powers of 2 by Vaughn Aubuchon
- ↑ Weisstein, Eric W. "Zero." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/Zero.html
- ↑ http://www.dailyjournal.net/view/story/78bb0782489647b296dce57dfd1e6b36/US--Largest-Prime-Number
- ↑ Warren Jr., Henry S. (2002). Hacker's Delight. Addison Wesley. p. 48. ISBN 978-0-201-91465-8.
- ↑ Paweł Strzelecki (1994). "O potęgach dwójki (About powers of two)" (in Polish). Delta.
External links
- "Sloane's A000079 : 2^{n}". The On-Line Encyclopedia of Integer Sequences. OEIS Foundation. (Powers of two)
- "Sloane's A001146 : 2^{(2n)}". The On-Line Encyclopedia of Integer Sequences. OEIS Foundation. (Powers of two whose exponents are powers of two)