CSUN Comp 222: Binary Systems
Practice Exam
I. Fundamental Warm-Up (15 Points)
1. Base Conversion Fundamentals (5 Points)
Question 1.1: Convert the decimal number
21410
into its equivalent 8-bit unsigned
binary representation and its hexadecimal representation.
Question 1.2: Convert the binary number
11011011.0112
into its equivalent
hexadecimal representation and decimal representation.
2. Hexadecimal and Binary Fractions (5 Points)
Question 2.1: Convert the hexadecimal number
3D.816
into its equivalent decimal
value.
Question 2.2: Convert the decimal fractional number
0.312510
into its binary
equivalent.
3. 2s Complement Representation (5 Points)
Question 3.1: Using an 8-bit 2s Complement system, represent the decimal
number
−6110
. Show your intermediate steps (positive binary, 1s complement, 2s
complement).
Question 3.2: The 8-bit 2s Complement binary number is
100110012
. What is its
equivalent decimal value?
II. Intermediate Applications: Arithmetic and Range (30 Points)
4. 2s Complement Addition and Overflow (10 Points)
Using 8-bit 2s Complement arithmetic, perform the following two additions. In
each case, show the binary addition, convert the final binary result to decimal to
verify, and state explicitly whether an Overflow occurred.
Question 4.1:
9510 +4010
Question 4.2:
(−10010)+(−5010)
5. 2s Complement Subtraction (10 Points)
Question 5.1: Using 8-bit 2s Complement arithmetic (performing
A − B
as
A+(− B )
), calculate
3510 −7210
. Show the binary operation and verify the final result
in decimal.
6. System Range and Bit Requirements (10 Points)
Question 6.1: What is the largest decimal number that can be represented using a
12-bit unsigned integer system?
Question 6.2: What is the range of decimal values (smallest negative to largest
positive) that can be represented using a 10-bit 2s Complement system?
III. Advanced Challenges: Floating Point and Bitwise Operations (25 Points)
7. IEEE 754 Single Precision (15 Points)
This section tests your understanding of the complex internal structure of floating-
point numbers.
Question 7.1 (Decoding):
The following 32-bit pattern is an IEEE 754 Single Precision floating-point number.
Determine the decimal value it represents.
1 1000000101000000000000000000000
Question 7.2 (Encoding):
Represent the decimal value
20.510
in the complete 32-bit IEEE 754 Single Precision
format.
Hint:
Sign: 1 bit
Exponent: 8 bits, Bias
¿127
Significand (Mantissa): 23 bits (with the implicit leading 1)
8. Bitwise Operations and Masking (10 Points)
Question 8.1:
A 16-bit register
R
currently holds the hexadecimal value
B3A516
. If a processor
instruction performs an Arithmetic Right Shift of 4 bits on
R
, what is the new
hexadecimal value in the register?
Question 8.2:
You want to perform a bitwise operation on the 8-bit binary value
X=110100112
to
toggle (invert) only the middle four bits (bits 4, 3, 2, 1, assuming bit 0 is the LSB)
while leaving the outer four bits (bits 7, 6, 5, 0) unchanged.
1. What is the required Masking value (in binary)?
2. What is the resulting binary value after the operation? (Specify the bitwise
operation used.)
Detailed Solutions and Explanations🔑
I. Fundamental Warm-Up Solutions
1. Base Conversion Fundamentals
Question 1.1: Convert
21410
to 8-bit Binary and Hexadecimal.
A. Decimal to Binary (Repeated Division by 2):
Division Quotient Remainder (Binary Digit)
214 ÷2
107
0
(LSB)
107 ÷2
53
1
53 ÷2
26
1
26 ÷2
13
0
13 ÷2
6
1
6÷2
3
0
3÷2
1
1
1÷2
0
1
(MSB)
Reading the remainders from bottom to top:
110101102
.
Result (Binary):
110101102
B. Binary to Hexadecimal (Grouping by 4 bits):
Group the 8-bit binary result:
1101
¿
0110
¿
Result (Hexadecimal):
D616
Question 1.2: Convert
11011011.0112
to Hexadecimal and Decimal.
A. Binary to Hexadecimal:
Group the bits in sets of four, adding a leading zero and a trailing zero if necessary:
1101
¿
1011
¿
.0110
¿
Result (Hexadecimal):
DB .616
B. Binary to Decimal (Positional Notation):
1⋅27+1⋅26+0⋅25+1⋅24+1⋅23+0⋅22+1⋅21+1⋅20+0⋅2−1+1⋅2−2+1⋅2−3=128+64 +0+16+8+0+2+1+0+0.25+0.125=219+0.375
Result (Decimal):
219.37510
2. Hexadecimal and Binary Fractions
Question 2.1: Convert
3D.816
to Decimal.
3D.816=3⋅161+13 ⋅160+8⋅16−1=48+13+8/16=61+0.5
Result:
61.510
Question 2.2: Convert
0.312510
to Binary.
Method: Repeated Multiplication by 2
Multiplicatio
n Product Integer (Binary Digit)
0.3125 ×2
0.625
0
0.625 ×2
1.25
1
0.25 ×2
0.5
0
0.5 ×2
1.0
1
Reading the integer parts from top to bottom:
0.01012
.
Result:
0.01012
3. 2s Complement Representation
Question 3.1: Represent
−6110
using 8-bit 2s Complement.
1. Positive Binary
(+6110 )
:
o
6110=001111012
(Padded to 8 bits)
2. 1s Complement (Invert all bits):
o
110000102
3. 2s Complement (Add 1):
o
110000102+12=110000112
Result:
110000112
Question 3.2: Find the decimal value of
100110012
(8-bit 2s Complement).
1. Sign Check: MSB is
1
, so the number is negative.
2. Find the 2s Complement (Absolute Value):
o
100110012
(Original)
o
011001102
(1s Complement)
o
011001102+12=011001112
(2s Complement/Magnitude)
3. Convert Magnitude to Decimal:
o
011001112=0⋅27+1⋅26+1⋅25+0⋅24+0⋅23+1⋅22+1⋅21+1⋅20
o
¿64+32+4+2+1=10310
4. Final Value: The number is
−103
.
Result:
−10310
II. Intermediate Applications: Arithmetic and Range Solutions
The 8-bit 2s Complement range is from
−128
to
+127
.
4. 2s Complement Addition and Overflow
Question 4.1:
9510 +4010
(Expected result:
13510
)
1. Convert to 8-bit 2s Complement:
o
9510=010111112
o
4010=001010002
2. Binary Addition:
00001110 ←Carries
01011111 (+95)
+¿00101000 (+40)
10001000 (−120)
3. Result Analysis and Verification:
oThe 8-bit result is
100010002
.
oThe MSB is
1
, indicating a negative number.
o
100010002
in decimal is
−120
.
4. Overflow Detection:
oWe added two positive numbers (
01011111
and
00101000
) and the
result was a negative number (
10001000
).
oThe expected result (
135
) is outside the positive range limit (
+127
).
Overflow Status: OVERFLOW OCCURRED
Question 4.2:
(−10010)+(−5010)
(Expected result:
−15010
)
1. Convert to 8-bit 2s Complement:
o
+10010=011001002
.
→ −10010=100110112+12=100111002
o
+5010=001100102
.
→ −5010=110011012+12=110011102
2. Binary Addition:
10001110 ←Carries
10011100 (−100)
+¿11001110 (−50)
(1)¿
(+106)¿
3. Result Analysis and Verification:
oThe final carry-out (9th bit) is ignored.
oThe 8-bit result is
011010102
.
oThe MSB is
0
, indicating a positive number.
o
011010102
in decimal is
64+32+8+2=106
.
4. Overflow Detection:
oWe added two negative numbers (
10011100
and
11001110
) and the
result was a positive number (
01101010
).
oThe expected result (
−150
) is outside the negative range limit (
−128
).
Overflow Status: OVERFLOW OCCURRED
5. 2s Complement Subtraction
Question 5.1:
3510 −7210
(Expected result:
−3710
)
1. Convert to 8-bit 2s Complement:
o
3510=001000112
o
+7210=010010002
.
→ −7210=101101112+12=101110002
2. Perform Subtraction as Addition (
35+(−72)
):
00011000 ←Carries
00100011 (+35)
+¿10111000 (−72)
11011011 ¿
3. Result Verification:
oThe result is
110110112
. MSB is
1
(negative).
oFind the magnitude:
11011011 →00100100+1=001001012
.
o
001001012=32+4+1=3710
.
oThe final result is
−3710
.
Result (Binary):
110110112
(Equals
−3710
)
6. System Range and Bit Requirements
Question 6.1: Largest decimal number in 12-bit unsigned system.
The range for an
n
-bit unsigned system is
0
to
2n−1
.
For
n=12
:
212 −1=4096 −1=4095
.
Result:
409510
Question 6.2: Range for 10-bit 2s Complement system.
The range for an
n
-bit 2s Complement system is
−2n− 1
to
2n −1−1
.
For
n=10
:
o
n −1=9
oMinimum (Most negative):
−29=−512
oMaximum (Most positive):
29−1=512 −1=511
Result:
−51210
to
+51110
III. Advanced Challenges: Floating Point and Bitwise Operations Solutions
7. IEEE 754 Single Precision
Question 7.1 (Decoding):
1 1000000101000000000000000000000
1. Sign (S):
1
(The number is negative.)
2. Exponent (E):
100000012
o
100000012=128+1=12910
oTrue Exponent (
e
):
e=E − Bias=129 −127=2
3. Significand (M):
01000000000000000000000
oThe stored form is
1. M
, so
1.010000000000000000000002
.
4. Formula Application:
Value=¿
o
1.012=1+0⋅2−1+1⋅2−2=1+0.25=1.25
o
Value=−1⋅1.25⋅4=−5.0
Result:
−5.010
Question 7.2 (Encoding): Represent
20.510
in IEEE 754 Single Precision.
1. Sign (S): The number is positive.
S=0
.
2. Decimal to Binary Conversion:
o
2010=101002
o
0.510=0.12
oBinary value:
10100.12
3. Normalization: Shift the radix point left until one non-zero digit is to the left:
10100.12=1.010012×24
oTrue Exponent (
e
):
4
4. Exponent Field (E):
o
E=e+Bias=4+127=13110
o
13110=100000112
(8 bits)
5. Significand Field (M):
oThe significand is the fractional part after the
1.
:
01001
oPad to 23 bits:
01001000000000000000000
6. Final 32-bit Assembly:
0
¿
10000011
¿
01001000000000000000000
¿
Result:
01000001101001000000000000000000
8. Bitwise Operations and Masking
Question 8.1: Arithmetic Right Shift (4 bits) on
B3A516
.
1. Convert to 16-bit Binary:
B3A516 =1011
¿
0011
¿
1010
¿
0101
¿
1011 0011 1010 01012
2. Arithmetic Right Shift (ARS): ARS preserves the MSB (sign bit) to maintain
the values sign. The sign bit (the far left
1
) is copied into the vacant positions.
oOriginal: 1011 0011 1010 0101
oShift 4 times, padding with the sign bit (
1
):
1111 1011 0011 10102
3. Convert Result to Hexadecimal:
1111
¿
1011
¿
0011
¿
1010
¿
Result (Hex):
FB 3A16
Question 8.2: Toggle middle four bits of
X=110100112
.
1. Operation Used: The XOR (
⊕
) operation is used to toggle bits.
o
A⊕1=A
(toggles)
o
A⊕0=A
(leaves unchanged)
2. Required Masking Value: We need
1
s in the positions to be toggled (bits 4,
3, 2, 1) and
0
s elsewhere.
oMasking Value:
000111102
3. Perform XOR Operation:
11010011 (X)
⊕¿(Mask )¿11001101 ¿(Result )¿
Masking Value (Binary):
000111102
Result (Binary):
110011012
Operation Used: Bitwise XOR (
⊕
)