Sunteți pe pagina 1din 2

Website addresses are often full of random-seeming percent signs and extra

characters. But those symbols have a purpose: They show that certain characters
are encoded in hexadecimal numbers, or base 16.

Ordinarily, we write numbers in base 10. This means that the last digit of a whole
number is counted in units of one, while the digit to the left of it represents units of
10, and the next one over shows units of 100, and so on. This system probably
became standard because most of us have 10 fingers and use them as a starting
point for counting—though some cultures have used a different starting point, such
as the Mayans counting by 20 (using fingers and toes) or some indigenous people of
Mexico who use eight (using the spaces between fingers instead of the fingers
themselves).

The mathematical system in which digits mean different things depending on their
position is called “place value,” and it’s a convenient way to express large numbers
efficiently. It is more convenient than Roman numerals, for example, which quickly
become long strings even for a small number like 38 (XXXVIII).

Using a base other than 10 doesn’t change how numbers work, only how we think
about them—but that can be crucial. The idea of base 2, or binary, was key in the
development of computers. In binary, the value of each digit only multiplies by two:
Starting from the right, digits represent units, then twos, then fours, then eights and
so on.

In binary, only two numerals are needed—usually 0 and 1 are used, but
theoretically, they could be any two characters. This is a contrast to decimals, where
we need 10 symbols. A system that only requires two symbols is an advantage in
building computers, since it means the entire system can be constructed using
on/off switches: 0 corresponds to the off position, and 1 corresponds to the on
position.

A disadvantage is that you need a much longer string of digits to represent the same
value. In decimal, we can represent numbers up to 999 using strings that are just
three digits long, but in binary, the highest three-digit number is 111—equivalent to
decimal number seven.

This is where hexadecimal or base 16 comes in. If we allow ourselves 16 number


symbols, then our place values can multiply by 16 at each step. For example, the
number 321 represents one unit, two 16s and three 256s, so it is the same as the
decimal number 801.

The trouble is that hexadecimal requires 16 symbols, and our usual numerals only
go from 0 to 9. The solution is usually to use the letters A, B, C, D, E and F for the
extra symbols representing the decimal numbers 10 to 15.

This means that hexadecimal numbers can look like C9F, which represents F (i.e.,
15) units, nine 16s and C (i.e., 12) 256s—that is, 3,231. In coding, for instance, colors
can be represented as six-character strings in hexadecimal, which yields a total of
more than 16 million possible colors, starting at 000000 for pure black and running
through FFFFFF for pure white.

Working in different bases can seem like an arcane mathematical game, but
computers show us that what looks like complication in one context can be
simplification in another.

S-ar putea să vă placă și