本文整理汇总了Python中BitVector.isPowerOf2方法的典型用法代码示例。如果您正苦于以下问题:Python BitVector.isPowerOf2方法的具体用法?Python BitVector.isPowerOf2怎么用?Python BitVector.isPowerOf2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitVector
的用法示例。
在下文中一共展示了BitVector.isPowerOf2方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: import BitVector [as 别名]
# 或者: from BitVector import isPowerOf2 [as 别名]
print(bv.next_set_bit(5)) # 14
bv = BitVector( bitstring = '0000000000000001' )
print(bv.next_set_bit(5)) # 15
bv = BitVector( bitstring = '00000000000000001' )
print(bv.next_set_bit(5)) # 16
bv = BitVector( bitstring = '00000000000000000' )
print(bv.next_set_bit(5)) # -1
print("\nTesting rank_of_bit_set_at_index():")
bv = BitVector( bitstring = '01010101011100' )
print(bv.rank_of_bit_set_at_index( 10 )) # 6
print("\nTesting isPowerOf2():")
bv = BitVector( bitstring = '10000000001110' )
print("int value: " + str(int(bv))) # 826
print(bv.isPowerOf2()) # False
print("\nTesting isPowerOf2_sparse():")
print(bv.isPowerOf2_sparse()) # False
print("\nTesting reverse():")
bv = BitVector( bitstring = '0001100000000000001' )
print("original bv: " + str(bv)) # 0001100000000000001
print("reversed bv: " + str(bv.reverse())) # 1000000000000011000
print("\nTesting Greatest Common Divisor (gcd):")
bv1 = BitVector( bitstring = '01100110' )
print("first arg bv: " + str(bv1) + " of int value: " + str(int(bv1))) #102
bv2 = BitVector( bitstring = '011010' )
print("second arg bv: " + str(bv2) + " of int value: " + str(int(bv2)))# 26
bv = bv1.gcd( bv2 )
print("gcd bitvec is: " + str(bv) + " of int value: " + str(int(bv))) # 2