0% found this document useful (0 votes)
11 views46 pages

CS111 - Lecture Note 01b

This document provides an introduction to number systems and converting between decimal, binary, octal, and hexadecimal number systems. It discusses the basics of each number system, how computers use binary, and methods for converting numbers using division or multiplication algorithms by placing the remainder or multiplying place values. The objectives are to understand each number system and convert between them.

Uploaded by

Jaber Sangcopan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views46 pages

CS111 - Lecture Note 01b

This document provides an introduction to number systems and converting between decimal, binary, octal, and hexadecimal number systems. It discusses the basics of each number system, how computers use binary, and methods for converting numbers using division or multiplication algorithms by placing the remainder or multiplying place values. The objectives are to understand each number system and convert between them.

Uploaded by

Jaber Sangcopan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

Introduction to

Computing
(CS111)
Junar A. Landicho

[email protected]

The way to get started is
to quit talking and begin
doing.

Walt Disney
Topic 1:
Number System
Conversion
Objectives
By the end of this topic, students will be able to:
Understanding decimal, binary, octal and hexadecimal numbers.
Counting in decimal, binary, octal and hexadecimal systems.
Convert a number from one number system to another system.
Advantage of octal and hexadecimal systems.

CS 111 – Introduction to Computing


Overview
1. Number Systems
2. Converting from Decimal to Binary
3. Converting from Decimal to Octal
4. Converting from Decimal to Hexadecimal
5. Converting from Binary to Decimal
6. Converting from Binary to Hexadecimal
7. Converting from Octal to Decimal
8. Converting from Octal to Binary
9. Converting from Hexadecimal to Decimal
CS 111 – Introduction to Computing
How Computers Work
A computer does not have a human brain inside but
acts in many ways as though it does have a real
one.

A computer understand machine language. It sees


the letters as a series of 0’s and 1’s called binary
language.
Hexadecimal Number
System
It uses 16 digits to
Octal Number System represent values.
It uses 8 digits to
represent values.
Binary Number System
Can only understand two
digits – a 0 and 1.

CS 111 – Introduction to Computing


Decimal Number System

Decimal number system contains 10


digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9; and
that is why its base or radix is 10.
01234
Here radix means total number of
digits used in any systems. 56789

CS 111 – Introduction to Computing


Decimal Number System
The decimal number system is positional number system.

Example:

1x 10
=0 1
5 6 2 1 1
2 x 10 = 20
103 102 101 100
6 x 102 = 600
5 x 103 = 5000
CS 111 – Introduction to Computing
Binary Number System
The binary number system is also a
positional numbering system

01
Instead of using ten digits, 0-9, the binary
system uses only two digits, 0 and 1.
The binary system is also known as base 2.
The values of the position are calculated by
taking 2 to some power.
Why is the base 2 for binary numbers?
▪ Because we use 2 digits, the digits 0 and 1.

CS 111 – Introduction to Computing


Binary Number System
Example

1 011
11111111
1 0 1 1
23 22 21 20
00000000

CS 111 – Introduction to Computing


Octal Number System

Also known as the base 8 system


Uses digits 0,1, 2, 3, 4, 5, 6, 7 0123
4567
Readily converts to binary
Group of three (binary) digits can be
used to represent each octal digit

CS 111 – Introduction to Computing


Octal Number System
Example

123
574 5 7 4
602 82 81 80

CS 111 – Introduction to Computing


Hexadecimal Number System
Base 16 system
Uses digits 0,1,2,3,4,5,6,7,8,9 and
letters A,B,C,D,E,F
Group of four bits represent each
base 16 digits

CS 111 – Introduction to Computing


Binary Number System
Numbering Scale

CS 111 – Introduction to Computing


Significant Digits
Numbering Scale
Binary: 11101101
Most significant digit Least significant digit

Hexadecimal: 1D63A7A
Most significant digit Least significant digit

CS 111 – Introduction to Computing


Converting from Decimal to Binary
Make a list of the binary place values up to the number being
converted.
Perform successive divisions by 2, placing the remainder of 0
or 1 in each of the positions from right to left.
Continue until the quotient is zero.
Example: 4210
25 24 23 22 21 20
32 16 8 4 2 1
1 0 1 0 1 0
CS 111 – Introduction to Computing
Converting from Decimal to Binary

CS 111 – Introduction to Computing


Converting from Decimal to Binary

CS 111 – Introduction to Computing


Converting from Decimal to Binary
The easiest way to convert a decimal number to its binary
equivalent is to use the Division algorithm.
This method repeatedly divides a decimal number by 2 and
records the quotient and remainder.
The remainder digits (a sequence of zeros and ones) form the
binary equivalent in least significant to most significant digit
sequence.

CS 111 – Introduction to Computing


Division Algorithm

CS 111 – Introduction to Computing


Converting from Decimal to Binary
(Fractional)
Example:
Convert the decimal number 12.062510 into binary number

Solution:

CS 111 – Introduction to Computing


Converting from Decimal to Octal
Example:
31510 = 4738

Solution:

CS 111 – Introduction to Computing


Converting from Decimal to Octal
Convert from decimal to octal by using the repeated division
method used for decimal to binary conversion.
Divide the decimal number by 8
The first remainder is the LSB and the last is the MSB.
Example: convert 35910 to octal value

CS 111 – Introduction to Computing


Converting from Decimal to Octal
Convert 42710 to its octal equivalent

CS 111 – Introduction to Computing


Converting from Decimal to Octal
(Fractional)
Examples:
Convert the decimal number 225.22510 into octal number.

Solution:

CS 111 – Introduction to Computing


Converting from Decimal to
Hexadecimal
Example
31510 = 13B16

CS 111 – Introduction to Computing


Converting from Decimal to
Hexadecimal
Convert 83010 to its hexadecimal equivalent

CS 111 – Introduction to Computing


Converting from Decimal to
Hexadecimal (Fractional)
Examples:
Convert the decimal number 225.22510 into octal number.

Solution:

CS 111 – Introduction to Computing


Converting from Binary to Decimal
Example of a binary number and the values of the positions:

1 001 1 01
26 25 24 23 22 21 20

CS 111 – Introduction to Computing


Converting from Binary to Decimal

CS 111 – Introduction to Computing


Converting from Binary to Decimal
The easiest way for converting a binary number to its decimal
equivalent is to use Multiplication Algorithm.

Multiply the binary digits by increasing powers of two, starting


from the right.

Then, to find the decimal number equivalent, sum those


products.

CS 111 – Introduction to Computing


Multiplication Algorithm
Convert 101011012 to its decimal equivalent:

CS 111 – Introduction to Computing


Converting from Binary to Octal
Can be converted by grouping the binary bit in group of three
starting from LSB.

Octal is a base 8 system and equal to two the power of three,


so a digit in Octal is equal to three digit in binary system.

CS 111 – Introduction to Computing


Converting from Binary to Octal

CS 111 – Introduction to Computing


Converting from Binary to
Hexadecimal
Group the digits of the binary number of four starting from the
right.
Replace each group of four digits by an equivalent
hexadecimal digit

CS 111 – Introduction to Computing


Converting from Octal Decimal
Convert 6538 to its decimal equivalent

CS 111 – Introduction to Computing


Converting from Octal to Binary
Convert from octal to binary by converting each octal digit to a
three but binary equivalent.

Convert from binary to octal by grouping bits in threes starting


with the LSB
Each group is then converted to the octal equivalent.
Leading zeros can be added to the left of the MSB to fill out
the last group.
CS 111 – Introduction to Computing
Converting from Octal to Binary

CS 111 – Introduction to Computing


Converting from Octal to Binary
Each octal number converts to 3 binary digits.

CS 111 – Introduction to Computing


Converting from Hexadecimal to
Decimal
Convert 3B4F16 to its decimal equivalent:

CS 111 – Introduction to Computing


Converting from Hexadecimal to
Binary
To convert a hexadecimal to binary number, convert each
hexadecimal digits to its 4 but equivalent using the hexa
number.
Example: 23.AB16 = ___2

CS 111 – Introduction to Computing


Converting from Hexadecimal to Octal
There are two ways to convert it:
Hexadecimal to Decimal to Octal
Hexadecimal to Binary to Octal

CS 111 – Introduction to Computing


Converting from Hexadecimal to Octal
Hexadecimal to Binary to Octal

CS 111 – Introduction to Computing


Exercise
Conversion

Decimal Binary Octal Hexadeci


mal
59 ? ? ?
? 1011011 ? ?
? ? 45 ?
? ? ? BAD

CS 111 – Introduction to Computing


CS 111 – Introduction to Computing
</End>

You might also like