Finding something worth knowing…

Science

Why Link could never carry more than 255 rupees

In the original Legend of Zelda, the hero's wallet capped out at 255 rupees, and Pac-Man breaks down at level 256. Neither number is arbitrary. One byte of 8 bits holds exactly 256 values, from 0 to 255, and powers of two quietly set limits all over computing.

A power of two is 2 multiplied by itself some number of times: 1, 2, 4, 8, 16 and on up, doubling each step, while negative exponents give the halves, quarters and eighths. Computers count in binary, where every place value is a power of two and every digit is 0 or 1. So in binary a power of two looks like a 1 followed by zeros, just as a power of ten does in decimal. That makes multiplying or dividing by two trivial: slide every bit one place left or right, among the fastest operations a processor can perform.

A string of n bits can be set in 2 to the n ways, so an unsigned number stored in n bits runs from zero to one less than that power. Hence the recurring limits of 255 in 8-bit games. Processor registers are nearly always 8, 16, 32 or 64 bits wide, disk block sizes are almost always powers of two, and even screen resolutions lean on them: 640 is 128 times 5 and 480 is 32 times 15.

Memory units caused a naming muddle. Computer scientists used kilobyte for 1024 bytes, 2 to the tenth, while the metric kilo means 1000. The gap grows with each step up: after roughly 17 powers of 1024 the binary figure is half again as large as the decimal one. Standard binary prefixes such as kibi now mark the difference.

Mathematicians prize the numbers too. A prime one less than a power of two, such as 31, is a Mersenne prime, and one more, such as 257, can be a Fermat prime. Euclid showed that when a sum like 1 plus 2 plus 4 plus 8 plus 16 is prime, multiplying it by the last term yields a perfect number: 31 times 16 is 496, which equals the sum of its divisors. And the last digit of successive powers cycles endlessly through 2, 4, 8, 6.

Source: Power of two

Related

More in Science · All topics