Everything2
Near Matches
Ignore Exact
Full Text
Everything2

Convert any number to decimal

created by in10se

(idea) by in10se (2.9 hr) (print)   ?   (I like it!) 1 C! Wed Sep 04 2002 at 16:38:48

So you have a number in binary (or octal, hexadecimal, etc - your choice). You may understand how to use it in its own context, but its hard to conceptualize that number without it being in the common decimal system (Base 10) format. Below you will find out how to convert any number, of any base, to a comfortable and easy to understand decimal value. All your base are belong to us.

While you may never think of it like this, any number in decimal format can actually be represented by the sum of its digits multiplied by powers of ten. For example:

32764 = (3 x 10^4) + (2 x 10^3) + (7 x 10^2) + (6 x 10^1) + (4 x 10^0)

While most people are most familiar with numbers in base 10, this same method can be used to determine the decimal values for numbers of any base using five easy steps. The example below will show how to convert two common bases, Base 8 (octal) and Base 16 (hexadecimal), to Base 10, as well as a using the example on a number already in Base 10. For simplicity, the example will use a single number that is valid in all of these bases: 32764.

Before beginning, here are the answers that will be obtained. You may check them using any method of your choosing:

  • Octal to Decimal: 32764(8) = 13812(10)
  • Hexadecimal to Decimal: 32764(16) = 206692(10)
  1. Count the number of digits in the number. We will call this number N.
    Example:
    32764 has five digits, so N = 5
     
  2. Beginning with the least significant digit (i.e., the rightmost digit), start numbering the digits from 0 to N-1. We will call each of these numbers a "digit identifier".
    Example:
    4 3 2 1 0  <-- Digit Identifiers
    3 2 7 6 4
     
  3. Starting with the most significant digit (i.e., the leftmost digit), multiply this number by the base to the power of its "digit identifier"
    Examples:
    • Base 8 (Octal): (3 x 8^4)
    • Base 10 (Decimal): (3 x 10^4)
    • Base 16 (Hexadecimal): (3 x 16^4)
       
  4. Repeat Step #3 using the next digit to the right until you have used up all the digits.
    Examples:
    Base 8 (Octal)
    • Digit identifier 3: (2 x 8^3)
    • Digit identifier 2: (7 x 8^2)
    • Digit identifier 1: (6 x 8^1)
    • Digit identifier 0: (4 x 8^0)
    Base 10 (Decimal)
    • Digit identifier 3: (2 x 10^3)
    • Digit identifier 2: (7 x 10^2)
    • Digit identifier 1: (6 x 10^1)
    • Digit identifier 0: (4 x 10^0)
    Base 16 (Hexadecimal)
    • Digit identifier 3: (2 x 16^3)
    • Digit identifier 2: (7 x 16^2)
    • Digit identifier 1: (6 x 16^1)
    • Digit identifier 0: (4 x 16^0)
       
  5. Add up all the values.
    Examples:
    32764(8) (Octal) = (3 x 8^4) + (2 x 8^3) + (7 x 8^2) + (6 x 8^1) + (4 x 8^0) = 13812(10)
    32764(10) (Decimal) = (3 x 10^4) + (2 x 10^3) + (7 x 10^2) + (6 x 10^1) + (4 x 10^0) = 32764(10)
    32764(16) (Hexadecimal) = (3 x 16^4) + (2 x 16^3) + (7 x 16^2) + (6 x 16^1) + (4 x 16^0) = 206692(10)

I would like to acknowledge that there are other ways to convert a number of one base to base 10. However, these other methods are usually for converting one specific base to another specific base such as specifically oct to dec, hex to dec, bin to dec, etc. The method above works for converting any base to base 10.


printable version
chaos

All your base are belong to us Deathmatch: e vs pi Noding for Numbers sexagesimal numbers
penny negative zero The Number One Christian porn site on the internet number bases
Stupid math tricks prefixes for binary multiples Metric shortcuts for dummies bit twiddling
irrational number binary Using Emacs as a programmer's calculator Less Than Zero
Everything Kitchen Conversion Table Multiplying on your fingers KB octal
Maths for the masses 153 How to convert binary to English in your head Adolf Hitler has a Bacon number of 3
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
The best nodes of all time:
Koala
The gods
Erin McKeown
Convolvulaceae
II-V-I progression
Hit by the realization that they are all getting to know you nodes
Li Qingzhao
The California Power Crisis
Benford's Law
Wives, submit to your husbands
Why do joints crack?
.50 BMG
serotonin and suicide
New Writeups
Meezzio
Gotlandssnus(thing)
argv
Astral Plane(idea)
Madara
One Winged Angel(fiction)
Tom Rook
Talk is cheap(poetry)
shaogo
Adelle Davis(person)
Aerobe
race car g sfjsgsd(poetry)
Binah
Dream Log: July 5, 2008(dream)
StrawberryFrog
Forgotten things in space(idea)
antigravpussy
velvet revolution fairy tale(idea)
Heitah
Nerve agent VX(thing)
Pavlovna
shite(idea)
wonton
Days and nights come together in a slow falling down(fiction)
Pavlovna
wee(idea)
katherine
root log: July 2008(log)
Madara
There’s nothing like a trail of blood to find your way back home(fiction)
E2 is a by-product of the existence of The Everything Development Company