diff --git a/chapter_2/exercises.md b/chapter_2/exercises.md index faf7aae..153fa31 100644 --- a/chapter_2/exercises.md +++ b/chapter_2/exercises.md @@ -3647,3 +3647,200 @@ $$ A \wedge B \equiv (A \downarrow A)\downarrow(B \downarrow B) $$ So: $$ (((P \downarrow P)\downarrow Q) \downarrow ((P \downarrow P)\downarrow Q)\downarrow ((P \downarrow P)\downarrow Q)) \downarrow (((Q \downarrow Q)\downarrow P) \downarrow ((Q \downarrow Q)\downarrow P) \downarrow (Q \downarrow Q)) $$ + +--- + +**Exercise Set 2.5** + +Page 129 + +Represent the decimal integers in 1-6 in binary notation. + +1. $19$ + +2. $55$ + +3. $287$ + +4. $458$ + +5. $1609$ + +6. $1424$ + +Represent the integers in 7-12 in decimal notation. + +7. $1110_2$ + +8. $10111_2$ + +9. $110110_2$ + +10. $1100101_2$ + +11. $1000111_2$ + +12. $1011011_2$ + +Perform the arithmetic in 13-20 using binary notation. + +13. + +$$ +1011_2 \\ +\underline{+ 101_2} +$$ + +14. + +$$ +1001_2 \\ +\underline{+ 1011_2} +$$ + +15. + +$$ +101101_2 \\ +\underline{+ 11101_2} +$$ + +16. + +$$ +110111011_2 \\ +\underline{+ 1001011010_2} +$$ + +17. + +$$ +10100_2 \\ +\underline{+ 1101_2} +$$ + +18. + +$$ +11010_2 \\ +\underline{- 1101_2} +$$ + +19. + +$$ +101101_2 \\ +\underline{- 10011_2} +$$ + +20. + +$$ +1010100_2 \\ +\underline{- 10111_2} +$$ + +21. Give the output signals $S$ and $T$ for the circuit shown below if the input + signals $P$, $Q$, and $R$ are as specified. Note that this is _not_ the + circuit for a full-adder. + +a. $P = 1$, $Q = 1$, $R = 1$ + +b. $P = 0$, $Q = 1$, $R = 0$ + +c. $P = 1$, $Q = 0$, $R = 1$ + +(See Page 130) + +22. Add $11111111_2 + 1_2$ and convert the result to decimal notation, to verify + that $11111111_2 = (2^8 - 1)_10$. + +Find the 8-bit two's complements for the integers in 23-26. + +23. $-23$ + +24. $-67$ + +25. $-4$ + +26. $-115$ + +Find the decimal representations for the integers with the 8-bit two's +complements given in 27-30. + +27. $11010011$ + +28. $10011001$ + +29. $11110010$ + +30. $10111010$ + +Use 8-bit two's complements to compute the sums in 31-36. + +31. $57 + (-118)$ + +32. $62 + (-18)$ + +33. $(-6) + (-73)$ + +34. $89 + (-55)$ + +35. $(-15) + (-46)$ + +36. $123 + (-94)$ + +37. + +a. Show that when you apply the 8-bit two's complement procedure to the 8-bit +two's complement for $-128$, you get the 8-bit two's complement for $-128$. + +b. Show that if $a$, $b$, and $a + b$ are integers in the range $1$ through +$128$, then + +$$ (2^8 - a) + (2^8 - b) = (2^8 - (a + b)) + 2^8 \geq 2^8 + 2^7 $$ + +Explain why it follows that if integers $a$, $b$, and $a + b$ are all in the +range $1$ through $128$, then the 8-bit two's complement of $(-a) + (-b)$ is a +negative number. + +Convert the integers in 38-40 from hexadecimal to decimal notation. + +38. $A2BC_{16}$ + +39. $E0D_{16}$ + +40. $39EB_{16}$ + +Convert the integers in 41-43 from hexadecimal to binary notation. + +41. $1C0ABE_{16}$ + +42. $B53DF8_{16}$ + +43. $4ADF83_{16}$ + +Convert the integers in 44-46 from binary to hexadecimal notation. + +44. $00101110_2$ + +45. $1011011111000101_2$ + +46. $11001001011100_2$ + +47. **Octal Notation:** IN addition to binary and hexadecimal, computer + scientists also use _octal notation_ (base 8) to represent numbers. Octal + notation is based on the fact that any integer can be uniquely represented + as a sum of numbers of the form $d \cdot 8^n$, where each $n$ is a + nonnegative integer and each $d$ is one of the integers from $0$ to $7$. + Thus, for example, + $5073_8 = 5 \cdot 8^3 + 0 \cdot 8^2 + 7 \cdot 8^1 + 3 \cdot 8^0 = 2619_{10}$. + +a. Convert $61502_8$ to decimal notation. + +b. Convert $20763_8$ to decimal notation. + +c. Describe methods for converting integers from octal to binary notation and +the reverse that are similar to the methods used in Examples 2.5.9 and 2.5.10 +for converting back and forth from hexadecimal to binary notation. Give examples +showing that these methods result in correct answers. diff --git a/chapter_2/notes.md b/chapter_2/notes.md index 10b9b7a..c0930d1 100644 --- a/chapter_2/notes.md +++ b/chapter_2/notes.md @@ -320,3 +320,70 @@ Page 112 Two digital logic circuits are **equivalent** if, and only if, their input/output tables are identical. + +--- + +Page 122 + +**Definition** + +**The 8-bit two's complement** for an integer $a$ between -128 and 127 is the +8-bit binary representation for + +$$ +\begin{cases} +a & \text{if } a \geq 0 \\ +2^8 - |a| & \text{if } a < 0 +\end{cases} +$$ + +--- + +Page 123 + +**The 8-Bit Two's Complement for a Negative Integer** + +The 8-bit two's complement for a negative integer $a$ that is at least -128 can +be obtained as follows: + +- Write the 8-bit binary representation for $|a|$. + +- Switch all the 1's to 0's and all the 0's to 1's. (This is called flipping, or + complementing, the bits.) + +- Add 1 in binary notation. + +--- + +Page 124 + +To find the decimal representation of the negative integer with a given 8-bit +two's complement: + +- Apply the two's complement procedure to the given two's complement. + +- Write the decimal equivalent of the result. + +--- + +Page 125 + +To add two integers in the range -128 through 127 whose sum is also in the range +-128 through 127: + +- Convert both integers to their 8-bit two's complement representations. + +- Add the resulting integers using ordinary binary addition, discarding any + carry bit of 1 that may occur in the 28th position. + +- Convert the result back to decimal form. + +--- + +Page 128 + +To convert an integer from hexadecimal to binary notation: + +- Write each hexadecimal digit of the integer in 4-bit binary notation. + +- Juxtapose the results. diff --git a/chapter_2/test_yourself.md b/chapter_2/test_yourself.md index ae25ffe..084950e 100644 --- a/chapter_2/test_yourself.md +++ b/chapter_2/test_yourself.md @@ -174,3 +174,69 @@ NOT; AND _______ gate. NOT; OR + +--- + +**Test Yourself** + +Page 129 + +1. To represent a nonnegative integer in binary notation means to write it as a + sum of products of the form _______, where _______. + +$d \cdot 2^n$ $d = 1$, and $n$ is a nonnegative integer. + +2. To add integers in binary notation, you use the facts that $1_2 + 1_2 = $ + _______ and $1_2 + 1_2 + 1_2 = $ _______. + +$10_2$; $11_2$ + +3. To subtract integers in binary notation, you use the facts that $10_2 - 1_2 = + $ _______ and $11_2 - 1_2 = $ _______. + +$1_2$; $10_2$ + +4. A half-adder is a digital logic circuit that _______, and a full-adder is a + digital logic circuit that _______. + +outputs the sum of any two binary digits; outputs the sum of any three binary +digits + +5. If $a$ is an integer with $-128 \leq a \leq 127$, the 8-bit two's complement + of $a$ is _______ if $a \geq 0$ and is _______ if $a < 0$. + +The 8-bit representation of $a$; The 8-bit representation of $2^8 - |a|$ + +6. To find the 8-bit two's complement of a negative integer $a$ that is at least + -128, you _______, _______, and _______. + +- Write the 8-bit binary representation for $|a|$. + +- Switch all the 1's to 0's and all the 0's to 1's. (This is called flipping, or + complementing, the bits.) + +- Add 1 in binary notation. + +7. To add two integers in the range -128 through 127 whose sum is also in the + range -128 through 127, you _______, ______, _______, and _______. + +- Convert both integers to their 8-bit two's complement representations. + +- Add the resulting integers using ordinary binary addition, + +- Discarding any carry bit of 1 that may occur in the 28th position. + +- Convert the result back to decimal form. + +8. To represent a nonnegative integer in hexadecimal notation means to write it + as a sum of products of the form _______, where _______. + +$d \cdot 16^n$; $d = 0, 1, 2, \dots 9, A, B, C, D, E, F$ and $n$ is a +nonnegative integer. + +9. To convert a nonnegative integer from hexadecimal to binary notation, you + _______ and _______. + +- Write each hexadecimal digit of the integer in 4-bit binary notation. + +- Juxtapose the results.