Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Understanding Binary Numbers: From Decimal to Binary and Back - Prof. Jeffrey J. Mcconnell, Study notes of Computer Science

An introduction to decimal and binary number systems, explaining how to convert binary numbers to decimal and vice versa. It also covers octal and hexadecimal numbers and their relationships with binary and decimal systems.

Typology: Study notes

Pre 2010

Uploaded on 08/17/2009

koofers-user-5p9
koofers-user-5p9 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Binary Numbers
Jeffrey J. McConnell, Ph.D.
Introduction
Numbers represent quantities and can be expressed in any base. We are familiar with decimal numbers, which
are expressed in base 10. Binary numbers are the cornerstone of computing and are expressed in base 2. This
document will take a quick look at decimal numbers and then look at the binary number system.
Decimal Numbers
The digits of a decimal number are between 0 and 9, which is one smaller than the decimal base of 10. The
digits of a decimal number are called, from right to left, the ones digit, tens digit, hundreds digit, thousands
digit, and so on. That is because the quantity the number represents is that digit multiplied by 1, 10, 100, 1000,
and so on. For example, the number 1547 is 7 * 1 + 4 * 10 + 5 * 100 + 1 * 1000. Each of these positions
represents higher and higher powers of ten starting with a power of zero. The ones digit is multiplied by 100,
which is 1. The tens digit is multiplied by 101, which is 10. The hundreds digit is multiplied by 102, which is
100. The thousands digit is multiplied by 103, which is 1000. In the case of decimal numbers, the quantity
represented by the number is the number itself.
Binary Numbers
The digits of a binary number are 0 and 1, which is one smaller than the binary base of 2. We don’t have names
for the digits of a binary number but the process for a binary number is the same as a decimal number. The
quantity that a binary number represents is the digits of the binary number multiplied from right to left by
increasing powers of 2. For example, the binary number 110100101 is 1 * 1 + 0 * 2 + 1 * 4 + 0 * 8 + 0 * 16 +
1 * 32 + 0 * 64 + 1 * 128 + 1 * 256.
Converting a Binary Number to a Decimal Number
One way to convert a binary number to a decimal number is to determine the quantity that the number
represents, which is the decimal equivalent. For the previous example, the binary number 110100101
represents the quantity 1 * 1 + 0 * 2 + 1 * 4 + 0 * 8 + 0 * 16 + 1 * 32 + 0 * 64 + 1 * 128 + 1 * 256, which is
421.
A second way works from left to right in the binary number. This process will double the previous total and
then add the next digit of the number. At the start, the previous total is always zero. The chart below shows
how this would work for the previous example.
Previous total * 2 + digit new total
0 * 2 + 1 1
1 * 2 + 1 3
3 * 2 + 0 6
6 * 2 + 1 13
13 * 2 + 0 26
26 * 2 + 0 52
52 * 2 + 1 105
105 * 2 + 0 210
210 * 2 + 1 421
These two processes will always give the same answer so one can be used to check the accuracy of the
other.
pf3

Partial preview of the text

Download Understanding Binary Numbers: From Decimal to Binary and Back - Prof. Jeffrey J. Mcconnell and more Study notes Computer Science in PDF only on Docsity!

Binary Numbers

Jeffrey J. McConnell, Ph.D.

Introduction

Numbers represent quantities and can be expressed in any base. We are familiar with decimal numbers, which

are expressed in base 10. Binary numbers are the cornerstone of computing and are expressed in base 2. This

document will take a quick look at decimal numbers and then look at the binary number system.

Decimal Numbers

The digits of a decimal number are between 0 and 9, which is one smaller than the decimal base of 10. The

digits of a decimal number are called, from right to left, the ones digit, tens digit, hundreds digit, thousands

digit, and so on. That is because the quantity the number represents is that digit multiplied by 1, 10, 100, 1000,

and so on. For example, the number 1547 is 7 * 1 + 4 * 10 + 5 * 100 + 1 * 1000. Each of these positions

represents higher and higher powers of ten starting with a power of zero. The ones digit is multiplied by 10 0 ,

which is 1. The tens digit is multiplied by 10

1

, which is 10. The hundreds digit is multiplied by 10

2

, which is

100. The thousands digit is multiplied by 10

3

, which is 1000. In the case of decimal numbers, the quantity

represented by the number is the number itself.

Binary Numbers

The digits of a binary number are 0 and 1, which is one smaller than the binary base of 2. We don’t have names

for the digits of a binary number but the process for a binary number is the same as a decimal number. The

quantity that a binary number represents is the digits of the binary number multiplied from right to left by

increasing powers of 2. For example, the binary number 110100101 is 1 * 1 + 0 * 2 + 1 * 4 + 0 * 8 + 0 * 16 +

Converting a Binary Number to a Decimal Number

One way to convert a binary number to a decimal number is to determine the quantity that the number

represents, which is the decimal equivalent. For the previous example, the binary number 110100101

represents the quantity 1 * 1 + 0 * 2 + 1 * 4 + 0 * 8 + 0 * 16 + 1 * 32 + 0 * 64 + 1 * 128 + 1 * 256, which is

A second way works from left to right in the binary number. This process will double the previous total and

then add the next digit of the number. At the start, the previous total is always zero. The chart below shows

how this would work for the previous example.

Previous total * 2 + digit new total 0 * 2 + 1 1 1 * 2 + 1 3 3 * 2 + 0 6 6 * 2 + 1 13 13 * 2 + 0 26 26 * 2 + 0 52 52 * 2 + 1 105 105 * 2 + 0 210 210 * 2 + 1 421

These two processes will always give the same answer so one can be used to check the accuracy of the

other.

Let’s consider a second example with the binary number 1011010110. In this case, our table looks like the

following.

Previous total * 2 + digit new total 0 * 2 + 1 1 1 * 2 + 0 2 2 * 2 + 1 5 5 * 2 + 1 11 11 * 2 + 0 22 22 * 2 + 1 45 45 * 2 + 0 90 90 * 2 + 1 181 181 * 2 + 1 363 363 * 2 + 0 726

Doing the conversion by adding up the powers of 2 gives us 0 * 1 + 1 * 2 + 1 * 4 + 0 * 8 + 1 * 16 + 0 * 32 +

1 * 64 + 1 * 128 + 0 * 256 + 1 * 512, which also gives a decimal equivalent of 726.

Converting a Decimal Number to a Binary Number

When a decimal number is converted to a binary number, the digits of the binary number will be determined

from right to left. In this process, we repeatedly divide the number by 2 and see what the remainder of that

division is. The remainder will be 0 when the number is an even number and will be 1 when the number is an

odd number. The remainder represents the next digit of the binary number.

Number / 2 Result Remainder 421 / 2 210 1 210 / 2 105 0 105 / 2 52 1 52 / 2 26 0 26 / 2 13 0 13 / 2 6 1 6 / 2 3 0 3 / 2 1 1 1 / 2 0 1

If you read up in the last column, you will find the binary number 110100101, which is the number of our first

example. Let’s look as another example.

Number / 2 Result Remainder 726 / 2 363 0 363 / 2 181 1 181 / 2 90 1 90 / 2 45 0 45 / 2 22 1 22 / 2 11 0 11 / 2 5 1 5 / 2 2 1 2 / 2 1 0 1 / 2 0 1

Reading up the last column gives the binary number 1011010110, which is the second of our example numbers.