Decimals Challenge Practice
| # | Answer |
|---|---|
| 1 | Exact sum: 16.475. Rounded to 2 decimal places: 16.48. |
| 2 | Total before rounding: 53.73925. Displayed to 2 decimal places: 53.74. |
| 3 | A direct equality check may fail because many decimal values cannot be represented exactly in binary floating-point, so 0.1 + 0.2 may produce 0.30000000000000004 instead of exactly 0.3. A safe strategy is to compare the difference using a small tolerance (for example, absolute difference < 0.000001) or use a decimal type designed for exact base-10 arithmetic. |
| 4 | Average temperature = (21.4 + 21.6 + 21.5 + 21.7 + 21.8) / 5 = 107.9 / 5 = 21.58. If each reading is already stored with 1 decimal place, the values remain the same here, so the average rounded to 2 decimal places is still 21.58. |
| 5 | Subtotal = 3(12.49) + 2(7.95) = 37.47 + 15.90 = 53.37. After 10% discount: 53.37 × 0.90 = 48.033. After 8.25% tax: 48.033 × 1.0825 = 51.9957225. Final amount rounded to 2 decimal places: $52.00. |