We use number bases every day without realizing it. When we think about numbers in everyday life, we are almost always thinking of decimal numbers, or numbers in base 10, where each digit of a number can be one of ten values. People have ten fingers and ten toes (most of the time), so it seems natural to base a number system on ten. But, we are not required to use ten as a base. For example, in the movie Avatar, the Na’vi inhabitants have eight fingers and base their number system on eight because of that. Back on Earth, we see other bases use commonly in computing systems, such as binary (base 2) and hexadecimal (base 16).

When we wish to discuss non-ten bases, we use a leading notation like this: 0b1100111101 (binary for decimal 829). In common computer languages, we see, and we will use, this notation for the following bases:

  • Binary (Base 2): leading 0b
  • Octal (Base 8): leading 0o
  • Decimal (Base 10): leading nothing (this is what we use in everyday life!)
  • Hexadecimal (Base 16): leading 0x

The position of a number indicates its underlying value. The exponent starts at value zero and increases by one each time we move to the left. This statement is evident in the example.

For example, with 120, we have:

1102+2101+01001 \cdot 10^2 + 2 \cdot 10^1 + 0 \cdot 10^0

Let’s revisit the pattern from right to left: ones, tens, hundreds, thousands. If we multiply it out, we go from left to right again: hundreds, tens, ones. Here are the exponents from left to right: 2, 1, 0.

In order to convert numbers in non-decimal bases to their decimal counterpart that we intuitively understand, we rely on the base number and the position of each digit. Starting from right to left, we compute the base conversion of that individual digit and add the decimal equivalent of that digit’s position.

Let’s try that with binary! Let’s look at 100 in binary, or 0b100. Remember, we’re working in base 2, so our equation will now be

122+021+0201 \cdot2^2 + 0 \cdot 2^1 + 0 \cdot 2^0

This leaves us with 4 + 0 + 0, or 4. So 100 in binary is equal to 4 in base 10!



Let’s say we have a number in base 10 with 5 digits, like 24601.

If we were to break this number into its components, what would be the value of the exponent for the digit 2

Assign the value to checkpoint_1 in the code editor.


For any number, regardless of what base system we’re working in, what is the value of the exponent for the first digit (rightmost column)?

Assign this value to checkpoint_2 in the code editor.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?