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

Added ceil_pow2().

parent cd960890
No related branches found
No related tags found
No related merge requests found
...@@ -73,11 +73,17 @@ def greatest_common_div(A, B): ...@@ -73,11 +73,17 @@ def greatest_common_div(A, B):
return A return A
def ceil_div(num, den): def ceil_div(num, den):
""" Return integer ceil value of num / den """
return int(math.ceil( num / float(den) ) ) return int(math.ceil( num / float(den) ) )
def ceil_log2(num): def ceil_log2(num):
""" Return integer ceil value of log2(num) """
return int(math.ceil(math.log(int(num), 2) ) ) 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): def sel_a_b(sel, a, b):
if sel==True: if sel==True:
return a return a
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment