10 examples of 'ceil and floor in python' in Python

Every line of 'ceil and floor in python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
48def iround(x):
49 if (x < 0): return int(x-0.5)
50 return int(x+.5)
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

74def ifloor(x):
75 return int(floor(x))
58def log_floor(n, b):
59 """
60 The largest integer k such that b^k <= n.
61 """
62 p = 1
63 k = 0
64 while p <= n:
65 p *= b
66 k += 1
67 return k - 1
77def floor(x):
78 return Floor(float(x))
30def ceil(x):
31 return Ceil(float(x))
763@staticmethod
764def floor(n: Union[int, float], precision: int = 0) -> Union[int, float]:
765 pass
191def ceil_n(input_data, n):
192 """ Return the ceiling of the input, element-wise closed to devider n."""
193 return int(n * np.ceil(input_data / n))
36def _int(val):
37 """
38 Parse string as an int, even if it has decimals.
39
40 >>> _int('1.0')
41 1
42 >>> _int('1.5')
43 1
44 """
45 return floor(float(val))
71def roundup(n, q):
72 import math
73 return int(math.ceil(float(n) / float(q)) * q)
50def _log2_floor_filter(value):
51 """Returns the logarithm base 2 of the given value, rounded down.
52
53 Args:
54 value: int|float. The specified value.
55
56 Returns:
57 int. The rounded off value of logarithm base 2 of the given value.
58 """
59 return int(math.log(value, 2))

Related snippets