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

HO - Thinking Like A Computer Scientist

- The document discusses binary number systems, including representation of positive and negative numbers, addition, subtraction, multiplication, and conversion between binary, decimal, octal and hexadecimal number systems. - Key binary operations covered are addition using carry, subtraction using borrowing, and multiplication. Negative numbers can be represented using signed magnitude, one's complement and two's complement methods. - Examples show converting decimal numbers to binary and vice versa, as well as performing binary arithmetic and converting between number systems.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

HO - Thinking Like A Computer Scientist

- The document discusses binary number systems, including representation of positive and negative numbers, addition, subtraction, multiplication, and conversion between binary, decimal, octal and hexadecimal number systems. - Key binary operations covered are addition using carry, subtraction using borrowing, and multiplication. Negative numbers can be represented using signed magnitude, one's complement and two's complement methods. - Examples show converting decimal numbers to binary and vice versa, as well as performing binary arithmetic and converting between number systems.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 62






– –


Step 1. Fetch
Obtain program
instruction or data item
from memory
Step 4. Store Step 2.
Write result to Decode
memory Translate
instruction
into
Step 3. Execute commands
Carry out command
Step 1. Fetch
Obtain program
instruction or data item
from memory
Step 4. Store Step 2.
Write result to Decode
memory Translate
instruction
into
Step 3. Execute commands
Carry out command
What is it?



– …
– …

“There are only 10 types
of people in the world,
those who understand
binary, and those who
do not.”
• Repetitive division: 36 = 100100

36
Note: The remainders incurred when the given
18 0 decimal number is divided by 2 shall form the
9 0 binary equivalent. The division will only terminate
4 1 when the quotient becomes 0.

2 0
1 0
0 1
Challenge






Note: If all the bits are 1,


then its decimal equivalent is
2n – 1 where n is the number
of 1s.
Challenge:
• Try converting the following binary
numbers to their decimal
equivalent and vice versa
12410 = _____2
7910 = ______ 2
111111112 = ______ 10
10000001 = ______
Addition
CARRY
• Examples:
a b. 1 1 1 1 1

1 1 0 0 1 0 1 1 0 0 1 1
+ +
0 1 0 0 1 1 1 1 0 1
1 1 1 0 1 1 1 0 1 0 0 0 0

1 0 1 1 0 0
+
1 1 0 1
1.)
3.)
1 1 0
+ 1 0 0 1 1
0 0 1 +
1 1 0 0 0

2.) 4.)

1 1 1 1 1
+ +
1 0 1 1 0
Multiplication
• Example:
a.

1 1 0 1 0 1
x

1 1
CARRY 1 1 1 0 1 0 1
+
1 1 0 1 0 1
1 0 0 1 1 1 1 1
c

1 0 1 1 0 0
+
1 0 1
1.)
3.)
1 1 0
x 1 1 0 1 1
1 1 x
1 0 0

2.) 4.)

1 1 1 0 1
x
1 0 x
1 0
• •
a. a.
b. b.
c. c.
d. d.
e. e.
Subtraction
• Examples:
a.

1 1 0 1 1 1
-
1 0 0 1 0 1
0 1 0 0 1 0

b.
borrow
0 10 0 10

1 0 0 1 1 0
-
1 0 1 0 1
0 1 0 0 0 1
Still on Subtraction

0 10
1 0 0 1
- 1 1 0 1
1 0 0
Negative Values in Binary Number
System
• Signed Magnitude (S.M.)
• One’s Complement (O.C.)
• Two’s Complement (T.C.)
– When working with the above, we restrict the
numbers in an n-bit system. In the next
slides, assume that we are working with a 6-bit
system
Signed Magnitude

001100 12

101100 -12

000101 5

100101 -5
One’s Complement

001100 12

110011 -12

000101 5

111010 -5
Two’s Complement

– 001100 12

110100 -12

000101 5

111011 -5
Still on Subtraction
















– …
– …








79

9 7

• 1 1

0 1







• 101 1012
001 001 0012
• 110 001 0002
• 3 38
• 1 7 08
5 2 58








– …
– …



– Answers:
244
– 61
– 3053
– 428
251

538

33 10

• 2 1

0 2

– Answers:
– 2D16
– 6216
4016
– 41B16
– 93416

• 0101 0101
0001 0001 0001
• 0110 0001 0000
• 1 B16
• 7 816
1 5 516


Decimal Binary Octal Hexadecimal

187

AF4

1101110

233

You might also like