utils.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:python-offchain 作者: TrueBitFoundation 项目源码 文件源码
def ctz(val, _type):
    cnt = int()
    power = int()
    if _type == 'uint32':
        bits = np.uint32(val)
        while power < 32:
            if val & 2**power == 0:
                cnt += 1
            else:
                break
            power += 1
    elif _type == 'uint64':
        bits = bin(np.uint64(val))
        while power < 64:
            if val & 2**power == 0:
                cnt += 1
            else:
                break
            power += 1
    else:
        raise Exception(Colors.red + "unsupported type passed to ctz." + Colors.ENDC)
    return cnt
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号