0% found this document useful (0 votes)
18 views9 pages

Group 4 - Assignment 1

The document contains solutions to various problems related to two's complement representation in binary and hexadecimal formats, including conversions and calculations involving negative numbers. It also discusses the range of integers that can be represented in 5-bit and 8-bit two's complement systems. Additionally, it includes a list of students with their names, matric numbers, and departments.

Uploaded by

newnessking30
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)
18 views9 pages

Group 4 - Assignment 1

The document contains solutions to various problems related to two's complement representation in binary and hexadecimal formats, including conversions and calculations involving negative numbers. It also discusses the range of integers that can be represented in 5-bit and 8-bit two's complement systems. Additionally, it includes a list of students with their names, matric numbers, and departments.

Uploaded by

newnessking30
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/ 9

COS 101

• GROUP 4
• ASSIGNMENT 1
A) What is the 6-bit two’s complement representation of the decimal
number -21?
To represent -21 in 6-bits two’s complement:
-21:
128 64 32 16 8 4 2 1
0 0 0 1 0 1 0 1
1 1 1 0 1 0 1 0
+
1
1 1 1 0 1 0 1 12
-21 = 1010112

B) What is the hexadecimal representation for decimal -51 encoded as


an 8-bit two’s complement number?

To represent -51 in 8—bit two’s complement:

-51
128 64 32 16 8 4 2 1
0 0 1 1 0 0 1 1
1 1 0 0 1 1 0 0
+
1
1 1 0 0 1 1 0 12
-51 = 11001101

Convert to hexadecimal = 1100( C ) 1101( D ) = 0×CD

C) The hexadecimal representation for an 8-bit two’s complement


number is 0xD6. What is its decimal representation?

The hexadecimal representation for an 8-bit two’s compliment


number is 0xD6

128 64 32 16 8 4 2 1
1 1 0 1 0 1 1 0
0 0 1 0 1 0 0 1
+
1
0 0 1 0 1 0 1 02
To get the decimal representation of 0xD6:
128 64 32 16 8 4 2 1
0 0 1 0 1 0 1 0
Adding the most significant bits (1) :
32+8+2= 42
Back to the binary form of 0xD6 (110101102 ) Which is a negative
binary form
Therefore, ANS= -42
D) Since the start of official pitching statistics in 1988, the highest
number of pitches in a single game has been 172. Assuming that
remains the upper bound on pitch count, how many bits would we
need to record the pitch count for each game as a two’s complement
binary number?

The highest number of pitches in a single game is 172. since it is non-


negative number two’s compliment. Then :

172:
128 64 32 16 8 4 2 1
1 0 1 0 1 1 0 02
172101011002 (8-bits)
B. E) Can the value of the sum of two 2’s complement numbers
0xB3 + 0x47 be represented using an 8-bit 2’s complement
representation? If so, what is the sum in hex? If not, write NO.

YES
128 64 32 16 8 4 2 1
Conversion: 0xB3= 1 0 1 1 0 0 1 1
0 1 0 0 1 1 00
+
1
0 1 0 0 1 1 01

Convert to decimal :
01001101 = 64+8+4+1=77
Most significant bits is = 1
Then : ans = - 77
128 64 32 16 8 4 2 1
Conversion: 0x47= 0 1 0 0 0 1 1 1

Convert to decimal :
01001101 = 64+4+2+1=71
0×B3= -77
0×47= 71
-77 + 71 = -6
Conversion of -6 to 8-bits two’s complement:
-6 : 128 64 32 16 8 4 2 1
0 0 0 0 0 1 1 0
1 1 1 1 1 0 0 1
+
1
1 1 1 1 1 0 1 02
1111= F
1010= A
ANS: 0×FA
F) Can the value of the sum of two 2’s complement numbers 0xB3 +
0xB1 be represented using an 8-bit 2’s complement representation? If
so, what is the sum in hex? If not, write NO.

O×B3 + O×B1
OxB3 = 10110011= -77
OxB1 = 10110001= -79

Addition of both:
-77 + -79 = -156
Therefore the -156 donot fit in 8-bit two’s complement and the range
for 8-bits two’s complement is from -128 to 127. Since -156 is out of
this range it cannot be represented.
ANS= No
G) Please compute the value of the expression 0xBB – 8 using 8-bit
two’s complement arithmetic and give the result in decimal (base 10).

OxBB - 8
Convert OxBB to base two
B = 1011, B = 1011
128 64 32 16 8 4 2 1
1 0 1 1 1 0 1 1
0 1 0 0 0 1 0 0
+
1
0 1 0 0 0 1 0 12
To get the negative decimal
64 + 4 + 1 = -69
OxBB – 8 = -69 – 8 -77
TTherefore, the ANS = -77
H) What is the smallest (most negative) integer that can be
represented as an 8-bit two’s complement integer? Give your answer
as a decimal integer.

To get the decimal integer


128 64 32 16 8 4 2 1
1 0 0 0 0 0 0 02
The decimal integer = -128 (because the digit 1 represents a negative
number)

I) The following operations are performed on an 8-bit adder. Give the


8-bit sum produced for each, in hexadecimal.

i. 0xF0 + 0x34 =

0x________ ii.

0xF0 + 0x80 =

0x________
Solution
i. The sum of hexadecimal
OxFO + Ox34
F = 1111, 0 = 0000, 3 = 0011, 4 = 0100
1 1 1 1 0 0 0 0
+
0 0 1 1 0 1 0 0
10 0 1 0 0 1 0 0
001001002
0010 =2 , 0100=4
ANS= 0X24
I)ii. 0xFO + 0x8O
0xFO=11110000
0x8O=10000000
1 1 1 1 0 0 0 0
1 0 1 1 1 0 0 0
10 1 1 1 0 0 00
01110000
0111= 7 , 0000=0
ANS= 0x70
j) Using a 5-bit two’s complement representation, what is the range of
integers that can be represented with a single 5-bit quantity?
Solution
maximum number (2n-1-1)
minimum number -(2n-1)
ranging from -(2n-1) to (2n-1-1)
Where n = 5 bits
-(25-1) = -(24) = -16
(Zakari25-1-1)=(24-1)=16-1=15
The range of integers that can be represented with a 5-bit two’s
complement is from -16 to 15.
ATTENDANCE
NAMES MATRIC NUMBER DEPARTMENT
Al-Ameen Akinwumi 24/10MSS058 Software Engineering
Ajibola
Zakari Muhammad 24/04NSS533 Nursing Science
Fareedah
Falodun Blessing 24/04NSS420 Nursing Science
jumoke
Idowu fransica Ayomide 24/04NSS444 Nursing Science
Fgbamila Damilola 24/04NSS445 Nursing Science
Abosede
Ochidi Nafiu 24/10MSS055 Software Engineering
Muhammed
Saba Deborah Boye 24/05BLL097 Medical Laboratory
Science
Tijani Rodiat Kofoworola 24/04NSS486 Nursing Science
Odili Daniella 24/04NSS465 Nursing Science
Nwayemoghor
Obilonu Joan 24/04NSS476 Nursing Science
Chizaram
Efeogehene Obukonise 24/10MSC032 Computer Science
Adewumi David 24/10MSC041 Computer Science
Oluwadarasimi
Arimoro Victory 24/04NSS529 Nursing Science

You might also like