f: y = (0 * (0 ≤ x ≤ 0.5)) + (0.5 < x ≤ 1.5) + (2 * (1.5 < x < 2.5)) + (3 * (2.5 < x ≤ 3.5)) + (4 * (3.5 < x ≤ 4.5)) + (5 * (4.5 < x))
g(x) = If[0 ≤ x ≤ 0.5, 0, If[0.5 < x ≤ 1.5, 1, If[1.5 < x ≤ 2.5, 2, If[2.5 < x ≤ 3.5, 3, If[3.5 < x ≤ 4.5, 4, If[x > 4.5, 5]]]]]]