Power of Two - Computer Science

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. As an unsigned integers these ways represent numbers from 0 (0…00) to 2n − 1 (1…11) inclusively. Corresponding signed integer are positive, negative numbers, 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 shuts down at level 255.

Powers of two are often used to measure computer memory. A byte is now considered to be eight bits (an octet, resulting in the possibility of 256 values (28). (The term byte has been, and in some case continues to be, used to be 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 standardised, 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 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 = 128 × 5, and 480 = 32 × 15. Put another way, they have fairly regular bit patterns.

Read more about this topic:  Power Of Two

Famous quotes containing the words computer and/or science:

    What, then, is the basic difference between today’s computer and an intelligent being? It is that the computer can be made to see but not to perceive. What matters here is not that the computer is without consciousness but that thus far it is incapable of the spontaneous grasp of pattern—a capacity essential to perception and intelligence.
    Rudolf Arnheim (b. 1904)

    The belief that established science and scholarship—which have so relentlessly excluded women from their making—are “objective” and “value-free” and that feminist studies are “unscholarly,” “biased,” and “ideological” dies hard. Yet the fact is that all science, and all scholarship, and all art are ideological; there is no neutrality in culture!
    Adrienne Rich (b. 1929)