,Connecting Discrete Mathematics and Computer Science
Solution Manual
This version: January 21, 2022
David Liben-Nowell
,
, 2 Basic Data Types
2.2 Booleans, Numbers, and Arithmetic
2.1 112 and 201
2.2 111 and 201
2.3 18 and 39
2.4 17 and 38
2.5 Yes: there‘s no fractional part in either x or y, so when they‘re summed
then there‘s still no fractional part.
a c
2.6can Yes: if we can
write x + y as write
ad+cb x = and y = with b = 0 and d = 0, then we
b d(and bd = 0 because bd
neither b = 0 nor d = 0).
2.7 No, and here‘s a counterexample: π and 1 − π are both irrational
numbers, but π + (1 − π) = 1, which is rational.
2.8 6, because ⌊2.5⌋ = 2 and ⌈3.75⌉ = 4 (and 2 + 4 = 6).
2.9 3, because ⌊3.14159⌋ = 3 and ⌈0.87853⌉ = 1 (and 3 · 1 = 3).
2.10 34 = 3 · 3 · 3 · 3 = 81, because ⌊3.14159⌋ = 3 and ⌈3.14159⌉ = 4.
2.11 The functions floor and truncate differ on negative numbers. For any
real number x, we have ⌊x⌋ ≤ x—even if x
is negative. That‘s not true for truncation. For example, ⌊−3.14159⌋ = −4 but
trunc(−3.14159) = −3 .14159 = −3.
2.12 ⌊x + 0.5⌋
2.13 0.1 · ⌊10x + 0.5⌋
Solution Manual
This version: January 21, 2022
David Liben-Nowell
,
, 2 Basic Data Types
2.2 Booleans, Numbers, and Arithmetic
2.1 112 and 201
2.2 111 and 201
2.3 18 and 39
2.4 17 and 38
2.5 Yes: there‘s no fractional part in either x or y, so when they‘re summed
then there‘s still no fractional part.
a c
2.6can Yes: if we can
write x + y as write
ad+cb x = and y = with b = 0 and d = 0, then we
b d(and bd = 0 because bd
neither b = 0 nor d = 0).
2.7 No, and here‘s a counterexample: π and 1 − π are both irrational
numbers, but π + (1 − π) = 1, which is rational.
2.8 6, because ⌊2.5⌋ = 2 and ⌈3.75⌉ = 4 (and 2 + 4 = 6).
2.9 3, because ⌊3.14159⌋ = 3 and ⌈0.87853⌉ = 1 (and 3 · 1 = 3).
2.10 34 = 3 · 3 · 3 · 3 = 81, because ⌊3.14159⌋ = 3 and ⌈3.14159⌉ = 4.
2.11 The functions floor and truncate differ on negative numbers. For any
real number x, we have ⌊x⌋ ≤ x—even if x
is negative. That‘s not true for truncation. For example, ⌊−3.14159⌋ = −4 but
trunc(−3.14159) = −3 .14159 = −3.
2.12 ⌊x + 0.5⌋
2.13 0.1 · ⌊10x + 0.5⌋