Lib.Krakatau.ssa.ssa_ops.bitwise_util.py Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of krakatau-lib Show documentation
Show all versions of krakatau-lib Show documentation
Assembler, disassebmler, decompiler and compiler tools library for Java.
from ..constraints import IntConstraint
import itertools, operator
def split_pow2ranges(x,y):
'''split given range into power of two ranges of form [x, x+2^k)'''
out = []
while x<=y:
#The largest power of two range of the form x,k
#has k min of number of zeros at end of x
#and the largest power of two that fits in y-x
bx = bin(x)
numzeroes = float('inf') if x==0 else (len(bx)-bx.rindex('1')-1)
k = min(numzeroes, (y-x+1).bit_length()-1)
out.append((x,k))
x += 1< k2:
(s1,k1),(s2,k2) = (s2,k2),(s1,k1)
mask1 = (1<
© 2015 - 2025 Weber Informatics LLC | Privacy Policy