<< Chapter < Page Chapter >> Page >
Worked examples for converting between binary, decimal and hexadecimal.

The number systems

What are the different number systems?

We are all familiar with the decimal system. However, when working with computers, we need to start with the binary system. The reason for this is that computers use gates (or switches) which only have two states, on and off. This is what translates to the 1's and 0's of binary. From there, it is possible to build up to other more useful systems such as the decimal system or the hexadecimal system.

This module contains worked examples of how to convert between the decimal, hexadecimal and binary.

Powers of 10 and 2

Before working through some examples, it will be useful to review how we use the decimal system. The decimal system can express any real rational number using the digits 0-9 and a minus sign. The places of the digits represent the power of ten that is being used. For example:

321 3 10 2 2 10 1 1 10 0
5023 5 10 3 0 10 2 2 10 1 3 10 0

In the same way, binary systems use 1's and 0's to express a number:

23 10111 (binary) 1 2 4 0 2 3 1 2 2 1 2 1 1 2 0

Binary - unsigned

The following examples show how to convert between unsigned binary and decimal values.

What is the decimal value of 10101 ?

  1. In this case, we are dealing with unsigned binary numbers. Our range of possible numbers are between 0 and 2 N 1 .

  2. 10101 1 2 4 0 2 3 1 2 2 0 2 1 1 2 0 1 2 4 1 2 2 1 16 4 1 21

Convert 011010 to decimal.

Write out the sum of each digit multiplied by its correct power of two:

011010 0 2 5 1 2 4 1 2 3 0 2 2 1 2 1 0 2 0 16 8 2 26

Convert the decimal number 47 to binary unsigned.

  1. For the decimal number 47, the largest multiple of two is 32 ( 2 5 ).

  2. 47 32 15
  3. 15 8 7
    7 4 3
    3 2 1
    1 1 0
  4. 47 32 8 4 2 1 2 5 2 3 2 2 2 1 2 0 101111(binary)

    Note: If necessary, you can check your answer by reversing the steps and converting it back to decimal.

Binary signed

Convert 11001110 (signed) to decimal value.

  1. The most significant bit is 1. This means it is negative.

  2. 1001110 2 6 2 3 2 2 2 1 64 8 4 2 78
  3. Thus the answer is -78.

Convert -98 to signed binary(8bit).

  1. In this case, the decimal number is negative so the most significant bit is 1.

  2. 98 2 6 98 64 34
  3. 34 2 5 34 32 2
    2 2 1 0
  4. 98 2 6 2 5 2 1 11100010

Convert 98 to signed binary(8bit).

  1. In this case, the decimal number is negative so the most significant bit is 0.

    Since we have already calculated the binary representation for 98, we can use the answer from the previous example. The steps are shown again to illustrate this.

  2. 98 2 6 98 64 34
  3. 34 2 5 34 32 2
    2 2 1 0
  4. 98 2 6 2 5 2 1 01100010

Binary - two's complement

The table below is a refresher for two's complement.

Two's complment
Two's Complement Decimal
0111 7
0110 6
0101 5
0100 4
0011 3
0010 2
0001 1
0000 0
1111 -1
1110 -2
1101 -3
1100 -4
1011 -5
1010 -6
1001 -7
1000 -8

Convert 001011 (two's complement 6-bit) to decimal value.

  1. In this case, the most significant bit is 0. The number is positive.

  2. 001011 1011 2 3 2 1 2 0 8 2 1 11

Convert 111011 (two's complement 6-bit) to decimal value

  1. The first bit is 1 so the number is negative.

  2. 11011 -->00100

  3. 00100 1 00101 2 2 2 0 5
  4. Thus the answer is -5.

Convert -13 to two's complement 8-bit binary.

  1. The number is negative so the most significant bit will be 1.

  2. 13 8 4 1 2 3 2 2 2 0 1101
  3. 1101 1 1100

    1100 -->0011

  4. 0011 -->11110011

Hexadecimal

A reference table is attached for conversion between decimal, hexadecimal and binary.

Hexadecimal reference
Decimal Hexadecimal Binary
0 0 0000
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
9 9 1001
10 A 1010
11 B 1011
12 C 1100
13 D 1101
14 E 1110
15 F 1111

Convert ABC (hexadecimal) to binary and decimal.

It may sometimes be easier to convert to decimal first and then binary.

  1. ABC -->10 , 11 , 12

  2. 10 16 2 11 16 1 12 16 0 2560 176 12 2748
  3. ABC -->10 + 11 + 12 -->1010 1011 1100

  4. 1010 1011 1100 -->101010111100

Convert 1010011110000001 to its decimal and hexadecimal values.

  1. 1010011110000001 -->1010 0111 1000 0001

  2. 1010 0111 1000 0001 -->A781

  3. A781 -->10, 7, 8, 1

    10 16 3 7 16 2 8 16 1 1 16 0 40960 1792 128 1 42881

Questions & Answers

what is biology
Hajah Reply
the study of living organisms and their interactions with one another and their environments
AI-Robot
what is biology
Victoria Reply
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
Joseph Reply
what is biology
Yousuf Reply
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
Joseph Reply
what is the blood cells
Shaker Reply
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
Abdullahi Reply
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
What is classification
ISCONT Reply
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
Kenna Reply
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
cell is the building block of life.
Condoleezza Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Precalculus with engineering applications. OpenStax CNX. Jan 24, 2011 Download for free at http://cnx.org/content/col11267/1.3
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Precalculus with engineering applications' conversation and receive update notifications?

Ask