Return the floor of x as an Integral. :param x: the number :return: the largest integer <= x. >>> import math >>> all(floor(n) == math.floor(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 floor(x: float) -> int: |
| 7 | """ |
| 8 | Return the floor of x as an Integral. |
| 9 | :param x: the number |
| 10 | :return: the largest integer <= x. |
| 11 | >>> import math |
| 12 | >>> all(floor(n) == math.floor(n) for n |
| 13 | ... in (1, -1, 0, -0, 1.1, -1.1, 1.0, -1.0, 1_000_000_000)) |
| 14 | True |
| 15 | """ |
| 16 | return int(x) if x - int(x) >= 0 else int(x) - 1 |
| 17 | |
| 18 | |
| 19 | if __name__ == "__main__": |
no outgoing calls
no test coverage detected