80 likes | 259 Views
Lecture 2: Number Systems. Supplementary Notes Complements Floating-point Numbers. Complements. “Find the complement of a number” is the short way of saying “find the negated value in the complement system”. For example, the two questions below are equivalent.
E N D
Lecture 2: Number Systems Supplementary Notes • Complements • Floating-point Numbers Number Systems Supplementary Notes
Complements • “Find the complement of a number” is the short way of saying “find the negated value in the complement system”. • For example, the two questions below are equivalent. • [4-bit base-2] Find the 1’s complement of 0110. Answer: 1001. • [4-bit base-2] If x is (0110)1s, what is -x in 1’s complement form? Answer: (1001)1s • So, “find the 1’s complement of 0110” is not asking for “how is 0110 represented in 1’s complement”. Complements
Complements • More examples: • [8-bit base-2] Find the 1’s complement of 101. Answer: 11111010. • [8-bit base-2] Find the 1’s complement of 11001000. Answer: 00110111. • [8-bit base-2] How is (101)2 represented in 1’s complement? Answer: 00000101. • [8-bit base-2] How is -(101)2 represented in 1’s complement? Answer: 11111010. • [8-bit base-2] Find the 2’s complement of 111000. Answer: 11001000. Complements
Complements • More examples: • [8-bit base-2] What is (111)2 in 2’s complement form? Answer: 00000111. • [8-bit base-2] What is -(111)2 in 2’s complement form? Answer: 11111001 • [6-bit base-2] What is (14)10 in 1’s complement form? Answer: (001110)1s. • [6-bit base-2] What is (-14)10 in 2’s complement form? Answer: (110010)2s. Complements
Complements • More examples: • [3-digit base-10] Find the 9’s complement of 25. Answer: 974. • [3-digit base-10] Find the 10’s complement of 123. Answer: 877. • [3-digit base-8] Find the 7’s complement of 712. Answer: 065. • [3-digit base-8] Find the 8’s complement of 123. Answer: 655. • [2-digit base-7] What is the radix complement of 15? Answer: 52. • [3-digit base-9] What is the diminished radix complement of 814? Answer: 074. Complements
Floating-point Numbers • Assume a 10-bit floating-point scheme with: 1-bit sign, 5-bit normalised mantissa, and 4-bit exponent. • What is this value: 1 11000 1001 ? • Sign bit is 1, so value is negative. • Mantissa is (0.11000)2, or (0.75)10 • What about exponent? • If exponent is unsigned, then exponent = 9. • If exponent is signed, and sign-and-magnitude is used, then exponent = -1. • If exponent is signed, and 1’s complement is used, then exponent = -6. • If exponent is signed, and 2’s complement is used, then exponent = -7. Floating-point Numbers
Floating-point Numbers • Therefore, • If exponent is unsigned, then value is -(0.11)2 x 29, or -(110000000)2, or -(384)10. • If exponent is in sign-and-magnitude, then value is -(0.11)2 x 2-1, or -(0.011)2, or (0.375)10. • If exponent is in 1’s complement form, then value is -(0.11)2 x 2-6, or -(0.00000011)2. • If exponent is in 2’s complement form, then value is -(0.11)2 x 2-7, or -(0.000000011)2. Floating-point Numbers