Midterm 1 Fall 22 Key

pdf

School

University of California, Irvine *

*We aren’t endorsed by this school

Course

31

Subject

Electrical Engineering

Date

Dec 6, 2023

Type

pdf

Pages

6

Report

Uploaded by KidVulture3852

EECS 31 Introduction to Digital Systems Midterm 1 Oct 13th, 2022 Name:__ Solution ___ This is a closed book, closed note quiz. You are not allowed to use a calculator. You may make any *reasonable* assumption but it must be stated clearly. For possible partial credit, be sure to show your work, but write your answer in the space indicated. Question 1 (5 points) Convert the following unsigned binary number to decimal. Show your work. 110101 2 = ____________________ 10 ࠵? ࠵? + ࠵? ࠵? + ࠵? ࠵? + ࠵? ࠵? = ࠵?࠵? Question 2 (10 points) (a) Find the decimal equivalent of the following octal number. Show your work. 123 = ____________________ 10 ࠵? × ࠵? ࠵? + ࠵? × ࠵? ࠵? + ࠵? × ࠵? ࠵? = ࠵?࠵? (b) Convert the following decimal number to binary. Use no more than 4 bits for the fraction part. Show your work. 3.14159 = ____________________ 2 Integer Part: 3 10 = 011 2 Fraction Part: 0.14159 × 2 = 0 .28318 0.28318 × 2 = 0 .56636 0.56636 × 2 = 1 .13272 0.13272 × 2 = 0 .26544 3.14159 = 011.0010 2 ࠵?࠵? 11.0010 2
Question 3 (18 points) What is the range of 32-bit binary number under the following assumptions? (a) Unsigned number? [0, 2 32 − 1] (b) Sign/magnitude representation? [−(2 31 − 1), 2 31 − 1] (c) Two’s complement representation? [−2 31 , 2 31 − 1] Question 4 (10 points) Convert the following decimal numbers to 8- bit 2’s complement numbers (indicate whether the decimal number would result in an overflow). −63 = _______________ 63 = 00111111 2 , flip every bits and plus 1, −63 = 11000001 2 , no overflow. 128 = _______________ 128 = 2 7 = 10000000 overflow, this is a negative representation in 8- bit 2’s complement.
Question 5 (10 points) How many 5- bit two’s complement numbers are greater than 0? How many are less than 0? How would your answers differ for sign/magnitude numbers? Positive numbers for 5- bit two’s complement are ࠵?࠵?࠵?࠵? 00001 ࠵?࠵? 2 4 − 1 . So, 15 numbers are greater than 0. Negative numbers for 5- bit two’s complement h ave 1 number more than positive numbers. So, 16 numbers are less than 0. For sign/magnitude, they have same number of positive and negative. So, 15 numbers are greater than 0, and 15 less than 0. Question 6 (10 points) Convert the following decimal numbers to 6- bit two’s complement binary numbers and subtract them. Indicate whether or not the difference overflows a 6-bit result. −28 10 − 3 10 −28 10 − 3 10 = (−28) + (−3) 28 = 011100 , and we can get −28 by flipping every bit and plus 1, so −28 = 100100 2 3 = 000011 , we we can get −3 by flipping every bit and plus 1, so −3 = 111101 2 100100 + 111101 = 1 100001 . Discard the carry out, the result is 100001 . There is no overflow.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Question 7 (12 points) Perform the following addition of unsigned binary numbers. Indicate whether or not the sum overflows the 4-bit result. (a) 1010 2 + 0110 2 (b) 1101 2 + 1001 2 (a) 1010 2 + 0110 2 = 1 0000 2 , and the carry out 1 is discarded. Overflow, because two unsigned number addition results in a smaller result. (b) 1101 2 + 1001 2 = 1 0110 , and the carry out 1 is discarded. Overflow, because two unsigned number addition results in a smaller result. Repeat the exercise, assuming that the binary numbers are in two’s complement form. (c) 1010 2 + 0110 2 (d) 1101 2 + 1001 2 (c) 1010 2 + 0110 2 = 1 0000 2 , and the carry out 1 is discarded. No overflow, a positive number adding a negative number never overflows. (d) 1101 2 + 1001 2 = 1 0110 , and the carry out 1 is discarded. Overflow, two negative numbers addition result in a positive number.
Question 8 (8 points) Convert the following 4- bit two’s complement numbers to 8 - bit two’s complement numbers. (a) 0110 2 (b) 1001 2 This is sign extension. Extend the sign bit. (a) 0110 2 = 00000110 2 (b) 1001 2 = 11111001 2 Question 9 (7 points) Perform the following addition of hexadecimal 2’s complement numbers. Indicate whether or not the sum overflows an 8-bit (two hex digit) result. 74 16 + 3࠵? 16 74 16 + 3࠵? 16 = 0111 0100 2 + 0011 1100 2 = 1011 0000 2 = ࠵?0 16 Overflow, because two positive numbers addition results in negative result.
Question 10 (5 points) What is the sequence of Gray Codes for 2-bit numbers? 00 01 11 10 or 00 10 11 01 Question 11 (5 points) Seven segment displays were created to display decimal numerals. With its 7 segments, the display can show numbers from 0 to 9. Complete the truth table for segment g. v ࠵? 3 ࠵? 2 ࠵? 1 ࠵? 0 g 0 0 0 0 0 0 1 0 0 0 1 0 2 0 0 1 0 1 3 0 0 1 1 1 4 0 1 0 0 1 5 0 1 0 1 1 6 0 1 1 0 1 7 0 1 1 1 0 8 1 0 0 0 1 9 1 0 0 1 1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help