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

CS0003 Module 1 - Binary Numbers

The document discusses the binary number system. It explains that binary uses only two symbols, 0 and 1, and is based on powers of two rather than ten. Binary arithmetic operations like addition, subtraction, multiplication and division are then introduced. Examples are provided for adding, subtracting, multiplying and dividing binary numbers.

Uploaded by

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

CS0003 Module 1 - Binary Numbers

The document discusses the binary number system. It explains that binary uses only two symbols, 0 and 1, and is based on powers of two rather than ten. Binary arithmetic operations like addition, subtraction, multiplication and division are then introduced. Examples are provided for adding, subtracting, multiplying and dividing binary numbers.

Uploaded by

stefa-07
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Module 1: Introduction

to Programming
Module 2: Binary
Number System
Base 2: The Binary Number System
• The word “binary” comes from the Latin word
bis, meaning double.
• Thus, the number base of the binary number
system is base 2.
• Since it is in base 2, two symbols are used in the
binary number system.
{0,1}
• This means that only the digits in the above set
can be used for each position in every place
value in a given binary number.

3
Base 2: The Binary Number System
1 1 0 0

• Note that the highlighted place value can be filled by


the digits in the set {0,1}.
• Thus, it can be increased by 1 until it reaches -
1 1 0 1

• At this point, the symbols that can be used to fill the


highlighted position has been exhausted. Increasing it
further causes a shift in place value, and resets the
initial place value to zero. Thus -
1 1 1 0
Base 2: The Binary Number System
• To avoid confusion, one should write a binary number
with base 2 as its subscript whenever necessary.

• Thus, the binary number 10110 should be written as

101102
• It should be read as “one-zero-one-one-zero base
two” and NOT “ten-thousand one-hundred ten” since
each phrase denotes an entirely different number.
Base 2: The Binary Number System
• Case Study: 101102
• We know that the decimal number 3474 can be
expressed as powers of 10 –
(3x103) + (4x102) + (7x101) + (4x100) = 347410
• In the same manner, the binary number 101102 can
be expressed as powers of 2 –
(1x24) + (0x23) + (1x22) + (1x21) + (0x20) = 2210
Note that the rightmost exponent starts from zero
and increases by 1 as the place value increases.
Hence, the binary number system is said to be in
base 2.
Binary Arithmetic

• Addition
• Subtraction
• Multiplication
• Division

7
Binary Addition

•Single Bit Addition Table


0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 10 Note “carry”
Example

Add the following binary numbers

1101
+0 1 1 1
Example

Add the following binary numbers


1 1
1101
+0 1 1 1
10100
Binary Subtraction

•Single Bit Subtraction Table


0 - 0 = 0
1 - 0 = 1
1 - 1 = 0
0 - 1 = 1 with a “borrow”
Example
Subtract the binary number below
1
1 1
00
1 101
-0111
0110
Binary Multiplication
•Single Bit Multiplication Table

0 1
0 0 0
1 0 1
Binary Multiplication
•Single Bit Multiplication Table
0 x 0 = 0
0 x 1 = 0
1 x 0 = 0
1 x 1 = 1
Example
Multiply the 1101
following binary x0111
numbers 1101
11010
Partial Products
110100
0000000
1011011
Binary Division

•Single Bit Division Table


0 / 0 = N/A
0 / 1 = 0
1 / 0 = N/A
1 / 1 = 1
Example
Divide the 0 0 01 Quotient

111 1101 Dividend


following binary 0
numbers 11
Divisor 00
110
000
1101
111
Remainder
110

You might also like