Skip to content
Snippets Groups Projects
Commit ea10dde3 authored by Eric Kooistra's avatar Eric Kooistra
Browse files

Added ceil_pow2().

parent cd960890
Branches
No related tags found
No related merge requests found
......@@ -73,11 +73,17 @@ def greatest_common_div(A, B):
return A
def ceil_div(num, den):
""" Return integer ceil value of num / den """
return int(math.ceil( num / float(den) ) )
def ceil_log2(num):
""" Return integer ceil value of log2(num) """
return int(math.ceil(math.log(int(num), 2) ) )
def ceil_pow2(num):
""" Return power of 2 value that is equal or greater than num """
return 2**ceil_log2(num)
def sel_a_b(sel, a, b):
if sel==True:
return a
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment