3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

How to Convert Between base-10, Hexadecimal, and Binary

How to Convert Between base-10, Hexadecimal, and Binary
There are 10 types of people in this world: Those who can read binary and those who can't.

Many electronic and microcontroller projects require the use of a particular base numbering system, such as BCD on thumbwheel switches, hexadecimal (base-16) on hex encoders, and binary in shift registers and dip switches.  Often it is necessary to convert between bases, for example, when using a decade counter and converting a BCD value of a switch into a base-10 (that is, decimal) value that can be easily displayed.  In particular, all math is done in binary in digital systems, as well as at the analog/digital interface (like when you sample a waveform or measure a voltage) using only two digits: 1 and 0.

This is a brief instructable on what numbers represent and how to convert between the bases in which they are represented. This was included in one of my other guides when I realized that it should be separated out and put into its own instructable. After reading this guide you should be able to look at a binary number like "11101011" and tell that it represents the number 235 or convert the hex value "0xC0E4" to its binary equivalent of "1100000011100100" and decimal representation of 19980 without the use of a calculator (unless you suck apples at addition,subtraction,or division, in which case I feel your pain and wholly suggest keeping your favorite calculator handy).

However, no heavy math is needed and you won't need to do anything outside of basic math so don't sweat it if you're mathematically challenged.  This is part of the fun side of math.
 
Remove these adsRemove these ads by Signing Up
 

Step 1Understanding Number Representations

Understanding Number Representations
Have you ever wondered why we use 10 numbers in our everyday numbering systems, represented by the numbers 0 through 9, instead of, say, 8 or 17 or why it's so easy for us to count by fives (5,10,15,20...) instead of by sevens?  The bold fact is that humans have five fingers on each hand, totally 10 and our numbering system evolved from using our fingers to count up things.  I'd happily bet that if we had six fingers on each hand, it would be quite natural for us to have 12 numbers in our base numbering system, say, zero through Þ.  You've probably already groked this concept.

As just mentioned and you probably already knew, a number's base dictates how many numbers are used in the counting system.  The most common bases are discussed next, but before that a brief detour on what --conceptually--a number means.  Let's take the base-10 number, 28810

Note that I follow convention when a common base is not implied and explicitly state the base as a subscript to the number.


Decimal (base-10, or denary)

What does 28810 mean, exactly?  This value explicates that this number encompasses two 100's, eight 10's, and 8 units.  This can be succinctly shown as:

28810 = (2 * 100) + (8 * 10) + (8 * 1)

-or-

28810 = (2 * 102) + (8 * 101) + (8 * 100)

           =  200 + 80 + 8

 

Generalized:

htun = (h * n2) + (t * n1) + (u * n0) where h=hundreds,t=tens,u=units

As read across left to right, each number increases the total value by that number * base to the power of its place.  This notation will become useful when I show you how to convert any base into base-10/decimal in the next step.  There's not much to say about denary until a few more steps.



« Previous StepDownload PDFView All StepsNext Step »
5 comments
Sep 22, 2010. 9:40 PMwestfw says:

You left out octal (base 8), which is just like base 10. If you're missing two fingers.

Sep 23, 2010. 9:51 AMwestfw says:
oops. I guess not. It was just missing from titles...
Sep 22, 2010. 11:48 AMmatstermind says:
where did you hear that joke from?

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
63
Followers
22
Author:nevdull(The Bold Scientist)
Gian is the VP Research & Development at Open Design Strategies and holds a BA in Molecular/Cellular Biology and an MS in Computer Science. He has a collection of 8-bit microcontrollers and a room fu...
more »