User:DavidJCobb/Why 255?

From ZeldaChaos
Jump to: navigation, search

In many glitches in many games, it is possible to get a value up to 255 -- but no higher. The 100+ Gold Skulltulas glitch in Legend of Zelda: Ocarina of Time can be used to get up to 255 Gold Skulltula Tokens, but no higher. To use another game as an example, the MISSINGNO. trick in Pokemon Red and Blue can be used to catch Pokemon over level 100; you can then use Rare Candies to level them up to Level 255 -- but no higher. This begs the question: why 255?

Variables

Well, the reason has to do with the size of the variable the game uses to store these values. You see, games store values in variables, which work very similarly to variables in math and algebra. But games have to reserve space for these variables, which means that the variables need to have a size limit.

So okay, we know why there's a maximum limit. But still, why 255?

Number Bases

Well, to understand this, we first need to know about number bases. Let's take a look at a base that we're already very familiar with: base-10, or the decimal number system. What's the highest number we can represent with one digit? 9. The highest number with two digits? 99. Three digits? 999. See a pattern?

The highest number that can be represented using n digits in base-B is B^n-1. So...

  • The highest number that can be represented using 1 digit in base-10 is 10^1-1 = 10-1 = 9
  • The highest number that can be represented using 2 digits in base-10 is 10^2-1 = 100-1 = 99
  • The highest number that can be represented using 3 digits in base-10 is 10^3-1 = 1000-1 = 999

Now, this pattern holds true for other number bases, including base-2, or binary. Base-2 is the number base that all computers use to store data; the only digits we can have in base-2 are zeroes and ones. Variables in a computer (or video game) are stored as base-2 numbers (though computers can convert between bases, they can only store base-2).

Now, some standard sizes for variables are:

  • bit = a one-digit binary number
    The highest number that can be represented using 1 digit in base-2 is 2^1-1 = 2-1 = 1
  • byte = an eight-digit binary number
    The highest number that can be represented using 8 digits in base-2 is 2^8-1 = 256-1 = 255

And there's our answer. The smallest size available for representing numbers greater than 1 is a byte, which can represent any numbers between 0 and 255.

Personal tools
Namespaces

Variants
Actions
Glitches
Navigation
Affiliates
Toolbox
Google AdSense