Everything2
Near Matches
Ignore Exact
Full Text
Everything2

Convert any number to decimal

created by in10se

(idea) by in10se (1.1 hr) (print)   ?   1 C! I like it! 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
153 How to convert binary to English in your head Maths for the masses 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
After stirring Everything, these nodes rose to the top:
Christmas with the Super-Heroes
Milkweed
War on Iraq 2003
Batman
Music's saddest time
Henry VI
April Trolls Day
naturally curly hair
Four great vows
An Encounter with Natalie
I like the way he reads poetry
The Michigan PBB disaster
VNV Nation
New Writeups
_lesra
for abby(thing)
Adaptive Child
Annie's garden salsa(recipe)
Simulacron3
Zig-Zag(thing)
Ouzo
questions(idea)
Ouzo
Special Grilled Cheese(fiction)
Noung
Tiananmen Square Massacre(idea)
aneurin
Lord St Clair(person)
artman2003
Assholes and Douchebags: A Comparison(person)
locke baron
Tyan Thunder K8WE(thing)
locke baron
Udaloy class destroyer(thing)
Scaevola
Same-sex marriage(idea)
SteveMurrayFromNZ
British Standard Handful(idea)
nailbiter
nerve stapling(thing)
locke baron
Multiple Myeloma(thing)
SubSane
blonde, freckles, skinny, short(person)
This page courtesy of The Everything Development Company