Computer Arithmetic - Discrete Mathematics - Solved Homework, Exercises of Mathematics

This home work exercise is very helpful for the student of discrete mathematics. The major points in the exercises are: Computer Arithmetic, 8-Bit Two's Complement, Decimal Number, Modulation Operations, First Iteration, Binary Number, Decimal Representation, Complement of Number, Mutual Relation, Base-2 Arithmetic

Typology: Exercises

2012/2013

Uploaded on 04/23/2013

sarangapani
sarangapani 🇮🇳

4.5

(10)

62 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
SP12-CSE20 Discrete Mathematics
Homework 1 Solution
April 17, 2012
1 Boolean Functions and Computer Arith-
metic
1.1 Problem 2.12
Find the 8-bit two’s complement of 6710.
We first convert it into binary format then calculate its two’s comple-
ment. We iteratively divide this decimal number by 16 and set each digit
(from lowest to highest) to be the remainder. For instance, 6710/2 = 33 and
6710 mod 2 = 1, so the first bit is set to be 1, and we replace 67 with 33
for the following division and modulation operations. In the end the binary
number is 1000011, which is only of 7 bits, so we add 0 to the high-end bit
and make it to be 01000011. The two’s complement is thus obtained by flip
all the bits then add it by 1, which turns out to be 10111101.
1.2 Problem 2.13
Find the 8-bit two’s complement of 10810.
As above, we first convert it into binary format then calculate its two’s
complement. We iteratively divide this decimal number by 16 and set each
digit (from lowest to highest) to be the remainder. For instance, originally
for the first iteration, we have 10810/2 = 54 and 10810 mod 2 = 0, so the
first bit is set to be 10, and we replace 108 with 54 for the following division
and modulation operations. In the end the binary number becomes 1101100,
which is only of 7 bits, so we add 0 to the high-end bit and make it to be
1
Docsity.com
pf3

Partial preview of the text

Download Computer Arithmetic - Discrete Mathematics - Solved Homework and more Exercises Mathematics in PDF only on Docsity!

SP12-CSE20 Discrete Mathematics

Homework 1 Solution

April 17, 2012

1 Boolean Functions and Computer Arith-

metic

1.1 Problem 2.

Find the 8-bit two’s complement of 67 10. We first convert it into binary format then calculate its two’s comple- ment. We iteratively divide this decimal number by 16 and set each digit (from lowest to highest) to be the remainder. For instance, 67 10 /2 = 33 and 6710 mod 2 = 1, so the first bit is set to be 1, and we replace 67 with 33 for the following division and modulation operations. In the end the binary number is 1000011, which is only of 7 bits, so we add 0 to the high-end bit and make it to be 01000011. The two’s complement is thus obtained by flip all the bits then add it by 1, which turns out to be 10111101.

1.2 Problem 2.

Find the 8-bit two’s complement of 108 10. As above, we first convert it into binary format then calculate its two’s complement. We iteratively divide this decimal number by 16 and set each digit (from lowest to highest) to be the remainder. For instance, originally for the first iteration, we have 108 10 /2 = 54 and 108 10 mod 2 = 0, so the first bit is set to be 10, and we replace 108 with 54 for the following division and modulation operations. In the end the binary number becomes 1101100, which is only of 7 bits, so we add 0 to the high-end bit and make it to be

  1. The two’s complement is thus obtained by flip all the bits then add it by 1, which turns out to be 10010100.

1.3 Problem 2.

The number 10001001 2 is the 8-bit two’s complement of a number k. What is the decimal representation of k? For every n-bit number a, its two’s complement, b, is calculated as b = 2 n^ − a. Notice that from this equation we can also obtain a = 2n^ − b, thus a is also the two’s complement of b, and it is a mutual relation. As a result, we can get the original binary number of k by flip all the bits of its two’s complement and add by one, which is 01110111 2. The decimal representation turns out to be 119.

1.4 Problem 2.

The number 10111010 2 is the 8-bit twos complement of a number k. What is the decimal representation of k? Similar as above, for every n-bit number a, its two’s complement, b, is calculated as b = 2n^ − a. Notice that from this equation we can also obtain a = 2n^ − b, thus a is also the two’s complement of b, and it is a mutual relation. As a result, we can get the original binary number of k by flip all the bits of its two’s complement and add by one, which is 01000110 2. The decimal representation turns out to be 70.

1.5 Problem 2.

Using base-2 arithmetic, compute 79 - 43. Then compute it using 8-bit two’s- complement registers. Remember to check for overflow. We first convert the two numbers into 8-bit binary formats, using the method as denoted above. 79 → 010011112 and 43 → 001010112. Then since 79 > 43, we take binary arithmetic operation on them and get the result as 00100100 2. In the other way, using two’s complement, we first convert the negative number −43 to be 11010101 2 and take the addition operation with 01001111 2. Notice that any carry bit is seen as overflow and will be discarded, and after bitwise addition the result turns out to be also