Return the ceiling of x as an Integral. :param x: the number :return: the smallest integer >= x. >>> import math >>> all(ceil(n) == math.ceil(n) for n ... in (1, -1, 0, -0, 1.1, -1.1, 1.0, -1.0, 1_000_000_000)) True
(x: float)
| 4 | |
| 5 | |
| 6 | def ceil(x: float) -> int: |
| 7 | """ |
| 8 | Return the ceiling of x as an Integral. |
| 9 | |
| 10 | :param x: the number |
| 11 | :return: the smallest integer >= x. |
| 12 | |
| 13 | >>> import math |
| 14 | >>> all(ceil(n) == math.ceil(n) for n |
| 15 | ... in (1, -1, 0, -0, 1.1, -1.1, 1.0, -1.0, 1_000_000_000)) |
| 16 | True |
| 17 | """ |
| 18 | return int(x) if x - int(x) <= 0 else int(x) + 1 |
| 19 | |
| 20 | |
| 21 | if __name__ == "__main__": |