/
NikolayIvkin
/
TheAlgorithms_Python
Обзор
Документация
Войти
/
NikolayIvkin
/
TheAlgorithms_Python
Код
Запросы
2
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
maths/floor.py
22 строки
483 B
Saksham Chawla
Add typing to maths/floor.py (#7056)
12 окт 2022, 21:42
Не верифицирован
12 окт 2022, 21:42
32ff336
Код
Авторство
О чём код?
""" https://en.wikipedia.org/wiki/Floor_and_ceiling_functions """ def floor(x: float) -> int: """ 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 """ return int(x) if x - int(x) >= 0 else int(x) - 1 if __name__ == "__main__": import doctest doctest.testmod()