Power Of 2 Article Index for
Power Of
Website Links For
Power
 

Information About

Power Of 2




Because two is the base of the binary system, powers of two are important to Computer Science . Specifically, two to the power of ''n'' is the number of ways the Bits in a binary integer of length ''n'' can be arranged, and thus numbers that are one less than a power of two denote the upper bounds of Integers in binary computers (one less because 0, not 1, is used as the lower bound). 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 a Byte , which is 8 bits long, being used to store the number, giving a maximum value of 28−1 = 255.

Powers of two also measure computer memory. A byte is eight (23) bits, and a kilobyte is 1,024 (210) bytes (standards prefer the word Kibibyte , as "kilobyte" also means 1,000 bytes). Nearly all Processor Registers have sizes that are powers of two, 32 or 64 being most common (see Word Size ).

Powers of two occur in a range of other places as well. For many Disk Drive s, 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 which 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, and 480 = 32 × 15. Put another way, they have fairly regular bit patterns.

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).


THE FIRST FORTY POWERS OF TWO



POWERS OF TWO WHOSE EXPONENTS ARE POWERS OF TWO


Because modern memory cells and registers often hold a number of bits which is a power of two, the most frequent powers of two to appear are those whose exponent is also a power of two. For example:

: 21 = 2
: 22 = 4
: 24 = 16
: 28 = 256
: 216 = 65,536
: 232 = 4,294,967,296
: 264 = 18,446,744,073,709,551,616
: 2128 = 340,282,366,920,938,463,463,374,607,431,768,211,456

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.


OTHER RECOGNIZABLE POWERS OF TWO


; 210 = 1,024
  • the digital approximation of the (or Kibibyte ).

  • 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.



FAST ALGORITHM TO CHECK IF THE NUMBER IS POWER OF TWO


The numerical Binary Representation of numbers allows to apply a very fast test if given number x is power of two:
:x is power of two \Leftrightarrow (x & (x-1)) equals zero.
where & is a Bitwise Logical AND Operator .


Examples:


EXTERNAL LINKS