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:

    The analogy between the mind and a computer fails for many reasons. The brain is constructed by principles that assure diversity and degeneracy. Unlike a computer, it has no replicative memory. It is historical and value driven. It forms categories by internal criteria and by constraints acting at many scales, not by means of a syntactically constructed program. The world with which the brain interacts is not unequivocally made up of classical categories.
    Gerald M. Edelman (b. 1928)

    As a science of the unconscious it is a therapeutic method, in the grand style, a method overarching the individual case. Call this, if you choose, a poet’s utopia.
    Thomas Mann (1875–1955)