0% found this document useful (0 votes)
52 views

Lesson 02 - Number Conversions and Arithmetic Operations

This document discusses number conversions between decimal, binary, and hexadecimal systems. It describes the remainder method for converting decimal numbers to binary and hexadecimal. Examples are provided to illustrate converting decimal to binary and hexadecimal, hexadecimal to binary, binary to hexadecimal, and arithmetic operations like addition and subtraction in different number systems. Exercises are included for students to practice number conversions and arithmetic.

Uploaded by

moviessacc
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Lesson 02 - Number Conversions and Arithmetic Operations

This document discusses number conversions between decimal, binary, and hexadecimal systems. It describes the remainder method for converting decimal numbers to binary and hexadecimal. Examples are provided to illustrate converting decimal to binary and hexadecimal, hexadecimal to binary, binary to hexadecimal, and arithmetic operations like addition and subtraction in different number systems. Exercises are included for students to practice number conversions and arithmetic.

Uploaded by

moviessacc
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Module 1 - Lesson 02: Number

Conversions and Arithmetic Operations


Converting Between Number Systems
In computer mathematics, you will be required to convert between the decimal, binary, and
hexadecimal number systems. In the previous lesson you implicitly learned how convert from
binary/hexadecimal to decimal by writing its expanded notation and evaluating it.

This week we will look at how to convert from:


 Decimal to Binary
 Decimal to Hexadecimal
 Hexadecimal to Binary
 Binary to Hexadecimal

Converting from Decimal to Binary/Hexadecimal


There are a number of methods we can employ to convert a decimal number to its binary equivalent.
The algorithm we will focus on is the remainder method.

The Remainder Method

1. Divide the decimal number by the base of the number system you want to convert to.
2. The remainder is the least significant (last) digit of the conversion.
3. Take the quotient from Step 2 and divide it by the base of the number system.
4. The remainder from Step 3 is the place value to the left of the converted equivalent.
5. Take the quotient from Step 4 and divide it by the base of the number system.
6. Repeat Steps 4 & 5 until the quotient is zero (0).

Example 1: Convert (17)dec to binary.

17 ÷ 2 = 8, 𝑅𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒 𝑜𝑓 1
8 ÷ 2 = 4, 𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅 𝑜𝑓 0
4 ÷ 2 = 2, 𝑅𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒 𝑜𝑓 0
2 ÷ 2 = 1, 𝑅𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒 𝑜𝑓 0
1 ÷ 2 = 0, 𝑅𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒 𝑜𝑓 1

Stop when your answer is 0. Final answer is 10001bin. Note, you start with the remainders from the
bottom up and write the answer from left to write.

MATH 18584 Lesson 02: Number Conversions & Arithmetic Operations


1
Example 2: Convert (152)dec to binary.

Example 3: Convert (555)dec to hexadecimal.

555 ÷ 16 = 34, 𝑅𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒 𝑜𝑓 11 or B


34 ÷ 16 = 2, 𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅 𝑜𝑓 2
2 ÷ 16 = 0, 𝑅𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒 𝑜𝑓 2

Stop when your answer is 0. Final answer is 22Bhex. Note, you start with the remainders from the
bottom up and write the answer from left to write.

Example 4: Convert (4110)dec to hexadecimal.

MATH 18584 Lesson 02: Number Conversions & Arithmetic Operations


2
**Alternative Method for Converting Decimal to Binary – Subtracting Powers of 2 (OPTIONAL)

Example: Convert (25)dec to binary.

Start with 25 and subtract the highest power of 2 possible.

25 – 24 = 9

1
24 23 22 21 20

Repeat by subtracting the next highest power of 2 possible.

9 – 23 = 1

1 1
4
2 23 22 21 20

Repeat by subtracting the next highest power of 2 possible.

1 – 20 = 0

1 1 1
4 3 2 1
2 2 2 2 20

Stop when you reach 0. Final answer is 11001bin.

Converting Hexadecimal to Binary


Hexadecimal numbers are useful in computer mathematics because larger binary numbers can be
represented in hexadecimal using less symbols. To convert a hexadecimal number to binary, write the
four bit binary equivalent for each hexit.

Example: Convert A1E7hex to binary.

MATH 18584 Lesson 02: Number Conversions & Arithmetic Operations


3
Converting Binary to Hexadecimal
Here is the algorithm to convert a binary number to its hexadecimal equivalent:

1. Start with the right-most (least significant) bit and group into sets of four bits.
2. If the last group contains less than four bits, pad to the left with zeros until the group has four
bits.
3. Convert each group of four bits to its hexadecimal equivalent.

Example: Convert 1011001000011111011bin to hexadecimal.

Exercise 1:

a) Convert (2004)dec to hexadecimal and then to binary.

b) Convert 8F2A1hex to binary.

c) Convert 1101010111000110111110bin to hexadecimal.

MATH 18584 Lesson 02: Number Conversions & Arithmetic Operations


4
Arithmetic Operations – Addition/Subtraction
Addition in the decimal number system:

When the sum of two digits is greater than 9, a carry-out of 1 is added to the next significant digit.

Example: 548 + 723

Addition in the binary number system:

 1+1=0 plus carry-out of 1


 1 + 1 + carry-in of 1 = 1 plus carry-out of 1
 1 + 0 + carry-in of 1 = 0 plus carry-out of 1
 0 + 0 + carry-in of 1 = 1 without any carry-out

Examples: 11011 + 11010 110011 + 100111

Addition in the hexadecimal number system

Hex addition is similar to decimal addition with the only difference being that the sum must be greater
than F (15) for a carry-out of 1 to be added to the next significant hexit.

Examples: D5E + 7BA 4C96 + E5A8

Subtraction in the decimal number system

If the subtrahend (the digit you are subtracting) is greater than the minuend (the digit you are
subtracting from), then you need to “borrow” (subtract 1) from the minuend of the next significant digit
(digit to the left) and add 10 (the base) to the minuend. Then you can subtract:

Example: 349 – 165

MATH 18584 Lesson 02: Number Conversions & Arithmetic Operations


5
Subtraction in the hexadecimal number system

The concept of “borrowing” is similar to that of the decimal number system, the only difference being
that you add 16 to the minuend instead of 10 (because hexadecimal is base 16!).

Examples: 7D3 – 29A F405 – 26E6

Exercise 2:

Add in binary: 101110 + 100111 0111111 + 0000001

Add in hexadecimal: 7F309 + 84BD7 FFFFF + 1

Subtract in hexadecimal: 78A4 – 5D3B BEEF – FAD FFFFF - ABCDE

MATH 18584 Lesson 02: Number Conversions & Arithmetic Operations


6
Exercises

1. Add the following binary numbers:

a) b)
0100110 0111111
+0110111 + 1

2. Add the following hexadecimal numbers:

a) b)
ABCD FFFFF
+ 4EFA + 1

c) d)
B46 7B6
+ D29 + FFF

3. Subtract the following hexadecimal numbers:

a) b) c)
F1 DEAF FFFFF
−1F −CAB − ABCDE

MATH 18584 Lesson 02: Number Conversions & Arithmetic Operations


7

You might also like