Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CS 230 Winter 2024

Assignment 2

Coverage: Logic Circuits, Integers and Non-Integer Numbers and Their Representations

Due Date: February 2, 11:59 p.m.

• All submissions are to be completed through MarkUs (https://markus.student.cs.uwaterloo.ca/markus_cs230_w/en/assignments)

The files submitted must be PDF files. For the PDF files you may submit electronically generated files from a source such as LaTeX, or you may submit scanned, hand-written solutions. However, the submitted file must be readable by the markers.

Double check  your submissions  in MarkUs  after you  have uploaded  them. It is your responsibility to ensure that the uploaded version is readable in MarkUs.

• Read the policy described in Learn regarding late submissions.

Check MarkUs to see how many 12-hour grace periods you have remaining.

• Solutions for assignments will not be posted.

For this and all future assignments and quizzes, the term bit sequence refers to a computer representation of data. Normally there will be a fixed length associated with the sequence. There will always be context associated with the sequence to explain how it should be interpreted.

The term decimal refers to base-10 numbers.

When we say x is a larger negative number than y, assume this means that the absolute value of x is greater than the absolute value of y.

1. [3 marks] Consider the following truth table:

A

B

C

D

Result

0

0

0

0

1

0

0

0

1

0

0

0

1

0

1

0

0

1

1

1

0

1

0

0

1

0

1

0

1

1

0

1

1

0

1

0

1

1

1

1

1

0

0

0

0

1

0

0

1

0

1

0

1

0

0

1

0

1

1

0

1

1

0

0

1

1

1

0

1

1

1

1

1

0

1

1

1

1

1

1

Write a Boolean expression that produces the result of this truth table. The question will be marked out of three. Any correct Boolean expression will receive a mark of 2 out of 3.

A correct expression that has fewer than 6 Boolean operators (any of ∧ ∨ ¬ | ↓ ⊕), will receive a mark of 3 out of 3.

Show your work going from the truth table to the final Boolean expression. Submit the file a2q1.pdf.

2. [12 marks] For this question, assume you working with 10-bit sequences using two’s complement representation for integers.

Show your work for all calculations. You may directly convert to and from positive decimal integer values and bit sequences representing binary numbers. For example, you may go directly from 1510 to 0000001111 without showing any additional steps.

For questions that require calculations where the arguments are bit sequences the answers must be bit sequences. The work of your solutions may not convert the values to decimal numbers. You may do those conversions yourself to check your answers.

• Clearly indicate any calculation with a result that causes an overflow.

(a) What is the bit sequence that represents the decimal integer -375?

(b) What is the decimal value of 1101010011?

(c) What is the sum of the bit sequences: 1000101001 + 1000011011?

(d) What is the sum of the bit sequences: 0101101001 + 0110101011?

(e) What is the sum of the bit sequences: 1101100101 + 1111101011?

(f) What is the difference of the bit sequences: 0001010010 - 0101100100?

(g) What is the difference of the bit sequences: 0101101001 - 1000011010? Submit the file a2q2.pdf.

3. [10 marks] For this question you will be working with binary and decimal numbers.

You should consider the numbers as mathematical values, i.e. there is no limit to the number of digits in the calculations or the solutions.

Show your work for the calculations. You may directly convert to and from positive decimal integer values and bit sequences. For example, you may go directly from 1510 to 11112 without showing any additional steps.

For questions that require calculations involving binary numbers, all work should be shown in terms of binary numbers. The work of your solutions may not convert the values to decimal numbers. You may do those conversions yourself to check your answers.

All of your answers must be precise numbers. This means in the case of fractional values, you should show the fraction or its equivalent using a radix point.

Note that you can represent integers and rational numbers exactly in any base. Just as the decimal number system has rational numbers that are represented with a repeating pattern after the decimal point, e.g. 1 = 0.3 some rational numbers in binary will have repeating patterns after the radix point. To be clear, 1 /= 0.3.

(a) Convert 1.011001111012 × 24 to decimal.

(b) Convert 50.601562510 to binary. Your answer should be shown as a binary number with a radix point.

(c) Convert 21.22510 to binary. Your answer should be shown as a binary number with a radix point.

(d) Calculate the sum of these binary numbers: 1.0100112 24 + 1.10110112 26 Your final answer must be shown using normalized representation.

(e) Calculate the product of these binary numbers: (1.101112 28)   (1.1012 25). Your final answer must be shown using normalized representation.

Submit the file a2q3.pdf.

4. [18 marks] For this question you will be working with floating point numbers. You must show how you determined the final answers for parts (c) through (j).

The floating point model uses 12-bit sequences with 1 bit for the sign, 5 bits for the exponent with a bias of 15, and 6 bits for the fraction.

The values for 0, infinity, NaN, and subnormal numbers are represented in a similar way to IEEE standard for floating point numbers.

For any results that cannot include all fractional bits in the bit sequence representation, extra bits should be truncated.

Unless otherwise indicated, in the cases where the results are decimal values, these answers must be precise. Precise values may be shown as a fraction or by writing out the exact digits of the decimal number.

The final decimal number cannot be written in scientific notation nor as a value multiplied by a power of 2.

(a) What is the bit sequence representation of −∞?

(b) What is the bit sequence representation of −0?

(c) What is the fifth largest, positive normal number that can be represented? Do not count infinity as a normal number. Give the bit sequence and the decimal value.

(d) What is the third, smallest, normal, positive number that can be represented? Do not count +0 as a positive number. Give the bit sequence and the decimal value as a fraction.

(e) What is the decimal equivalent of 101101010101? (f) What is the decimal equivalent of 010101011010?

(g) What is the bit sequence representation of the decimal value -17.25?

(h) What is the bit sequence representation of the decimal value 8197?

(i) What is the bit sequence representation of decimal value -41.6875?

(j) What is the bit sequence representation of the result of the following calculation? Your work shown for this question should be done as binary values.

101101101110 + 101001010100

Submit the file a2q4.pdf.