Floats, precision and big integers
- Stage
- 1
- Module
- M1.12
- Lessons
- 1
In this module
- Explain why floats can be slightly off, and avoid comparing them with
==. - Scale a calculation to integers to keep output exact.
- Work with integers of any size, and use
math.isqrtinstead ofmath.sqrtfor large values. - Round a division up with integer ceiling division.
Before this module
Lessons
Practice
Try these on the judges. Each link opens the problem on WMOJ or DMOJ.
- 2021 S1Crazy Fencing (opens on WMOJ in a new tab) WMOJ
Add up trapezoid areas measured from a list of heights and widths.
- 2020 S1Surmising a Sprinter's Speed (opens on DMOJ in a new tab) DMOJ
Find the top speed a sprinter must have reached, given a series of timed positions.
Why DMOJ: An early Senior problem, included here for extra practice.