TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
Lesson -5 Binary Arithmetic (1).pdffngmh
1. Mindanao Polytechnic College GSC
Mindanao Polytechnic College
General Santos City
Binary Arithmetic
Narene M. Nagares, MIT
Department of Information Technology
2. Mindanao Polytechnic College GSC
Binary Arithmetic
• Arithmetic operations in digital systems are
usually done in binary because design of logic
circuits to perform binary arithmetic is much
easier than for decimal.
• Binary arithmetic is carried out in much the
same manner as decimal, expect with the
addition and multiplication tables are much
simpler.
COMP1 - Computer Fundamentals & Programming 2
3. Mindanao Polytechnic College GSC
Binary Addition
COMP1 - Computer Fundamentals & Programming 3
• Addition table for binary numbers:
and carry 1 to the next column
Simple explanation why there is a
carry 1:
• When you do 1+1, the result in
decimal is 2, the binary number of
2 is 1 0, that is 2 bits.
• The 0 is written down and the 1 is
carried to the next column.
+
4. Mindanao Polytechnic College GSC
Binary Addition
• Example:
COMP1 - Computer Fundamentals & Programming 4
+
Adding three 1’s is equivalent to
1 1 in binary or 3 in decimal.
Breakdown:
1
+ 1
1 0
+ 1
1 1
5. Mindanao Polytechnic College GSC
Binary Addition
• Another Example:
COMP1 - Computer Fundamentals & Programming 5
*You may convert it in decimal
to check if your answer is correct.
6. Mindanao Polytechnic College GSC
Binary Subtraction
• Subtraction table for binary numbers:
COMP1 - Computer Fundamentals & Programming 6
and borrow 1 from the next column
When zero borrows 1 from the next
column, zero does not become 1, rather,
it becomes 1 0, the binary number of
decimal number 2. When you subtract 1
from 2, the result is 1.
7. Mindanao Polytechnic College GSC
Binary Subtraction
• Examples:
COMP1 - Computer Fundamentals & Programming 7
• Keep borrowing from
the next column until
you are able to find
the value 1.
• (1 0) represents the
number 2 in decimal .
When the previous
column borrows, the
value from the current
column becomes 1.
This becomes:
1 0
And 1 0 – 1 = 1.
8. Mindanao Polytechnic College GSC
Binary Multiplication
• The multiplication table for binary numbers:
COMP1 - Computer Fundamentals & Programming 8
9. Mindanao Polytechnic College GSC
Binary Multiplication
• Example: Multiplication of 1310 by 1110 in
binary:
COMP1 - Computer Fundamentals & Programming 9
10. Mindanao Polytechnic College GSC
Binary Multiplication
• To avoid carries greater than 1, you may add
partial products one at a time:
COMP1 - Computer Fundamentals & Programming 10
11. Mindanao Polytechnic College GSC
Binary Division
• Binary division is similar to decimal division,
except it is much easier because the only two
possible quotient digits are 0 and 1.
COMP1 - Computer Fundamentals & Programming 11
12. Mindanao Polytechnic College GSC
Binary Division
• Example: Division of 14510 by 1110 in binary:
• If we start comparing the divisor (1011) with the upper
four bits of the dividend (1001), we find that we cannot
subtract without a negative result, so we move the
divisor one place to the right and try again.
COMP1 - Computer Fundamentals & Programming 12
–
13. Mindanao Polytechnic College GSC
Binary Division
• Example: Division of 14510 by 1110 in binary:
• This time we can subtract 1011 from 10010 to give 111
as a result, so we put the first quotient bit of 1 above
10010. We then bring down the next dividend bit (0) to
get 1110 and shift the divisor right.
COMP1 - Computer Fundamentals & Programming 13
–
14. Mindanao Polytechnic College GSC
• Example: Division of 14510 by 1110 in binary:
• We then subtract 1011 from 1110 to get 11,
so the second quotient is 1.
Binary Division
COMP1 - Computer Fundamentals & Programming 14
–
15. Mindanao Polytechnic College GSC
• Example: Division of 14510 by 1110 in binary:
• When we bring down the next dividend bit,
the result is 110, and we cannot subtract the
shifted divisor, so the third quotient is 0.
Binary Division
COMP1 - Computer Fundamentals & Programming 15
–
16. Mindanao Polytechnic College GSC
• Example: Division of 14510 by 1110 in binary:
• We then bring down the last dividend bit and subtract 1011 from
1101 to get a final remainder of 10, and the last quotient bit is 1.
Binary Division
COMP1 - Computer Fundamentals & Programming 16
–
–
*The quotient is
1101 with a remainder of 10.
17. Mindanao Polytechnic College GSC
Exercises (Show your solution)
1. Add, subtract, and multiply in binary:
(a) 1111 and 1010
(b) 110110 and 11101
(c) 100100 and 10110
2. Divide in binary:
(a) 11101001 ÷ 101
(b) 1110010 ÷ 1001
Check your answers by multiplying out in binary and
adding the remainder.
COMP1 - Computer Fundamentals & Programming 17