MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / ceil

Function ceil

maths/ceil.py:6–18  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

4
5
6def 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
21if __name__ == "__main__":

Callers 7

piFunction · 0.90
odd_sieveFunction · 0.90
sol1.pyFile · 0.90
solutionFunction · 0.90
solutionFunction · 0.90
solutionFunction · 0.90
solutionFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected