Every line of 'python roundup to nearest 10' 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.

By copying the Snyk Code Snippets you agree to

this disclaimer

71 def roundup(n, q): 72 import math 73 return int(math.ceil(float(n) / float(q)) * q)

Important

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

4 def round_down(v): 5 return (int(v[0]), int(v[1]))

17 def round_up(x, base=1): 18 return int(base * round(float(x)/base))

248 def nearest(n): 249 """ 250 round up or down to nearest int returning an int 251 252 Used for selecting the nearest pixel position. 253 254 WARNING, this method is vectorised to handle a numpy array by NumpyImage 255 256 :param a number or array of numbers: virtual pixel position (x or y) 257 :return int: nearest integer (round up/down) 258 """ 259 if type(n) is None: return 260 n=float(n) # make sure n is a float 261 return int(round(n,0))

238 def round2 (n): 239 """ Get nearest power of two superior to n """ 240 f = 1 241 while f<n: 242 f*= 2 243 return f

312 def p_round(n, precision=5): 313 precision = int(precision) 314 return int(round(n / float(precision))) * precision

130 def roundup(val, width): 131 """roundup a value to N x width-bits""" 132 x = (width >> 3) - 1 133 return (val + x) & ~x

576 def _round_frac(x, precision): 577 """ 578 Round the fractional part of the given number 579 """ 580 if not np.isfinite(x) or x == 0: 581 return x 582 else: 583 frac, whole = np.modf(x) 584 if whole == 0: 585 digits = -int(np.floor(np.log10(abs(frac)))) - 1 + precision 586 else: 587 digits = precision 588 return np.around(x, digits)

4 def roundInt(a): return int(a+0.5)

27 def roundint(v): 28 return int(round(v))