当前位置: 首页>>代码示例>>Python>>正文


Python BitArray.int方法代码示例

本文整理汇总了Python中bitstring.BitArray.int方法的典型用法代码示例。如果您正苦于以下问题:Python BitArray.int方法的具体用法?Python BitArray.int怎么用?Python BitArray.int使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bitstring.BitArray的用法示例。


在下文中一共展示了BitArray.int方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: booths

# 需要导入模块: from bitstring import BitArray [as 别名]
# 或者: from bitstring.BitArray import int [as 别名]
def booths(m,r):
	x=len(bin(m))
	y=len(bin(r))
	totallength = x+y+1

	if m<0 and r<0 or r<0:
		bugbit = 1
	else:
		bugbit = 0

	A = BitArray(int = m,length = totallength) << (y+1)
	compliment = BitArray(int = -m,length = totallength) << (y+1)
	P = BitArray(int = r, length = totallength) 
	P = P<<1

	for i in range(1,y+1):
		if P[-2:]=='0b01':
			P = BitArray(int = P.int + A.int, length = totallength)
		elif P[-2:]=='0b10':
			P = BitArray(int = P.int + compliment.int, length = totallength)
		P = BitArray(int = P.int>>1, length = totallength)

	P = P[:-1]

	P.int = P.int + bugbit
	steps =""
	return '<h1>RESULT</h1><br>'+steps+'<br><h3>decimal value: '+str(P.int)+'</br><br> binary value: '+str(P.bin)+"</h3>"
开发者ID:neerajvashistha,项目名称:be-2,代码行数:29,代码来源:booths.py

示例2: booth

# 需要导入模块: from bitstring import BitArray [as 别名]
# 或者: from bitstring.BitArray import int [as 别名]
def booth(m,r):
	 x = len(bin(m))
	 y = len(bin(r))
	 #after both numbers are negative, for some reason, the answer is one less than whats expected.
	 if m < 0 and r < 0 or r < 0 :
	 	bugbit = 1
	 else:
		bugbit = 0
	 totalLength = x+y + 1
	 A = BitArray(int = m, length = totalLength) << (y+1)
	 compliment = BitArray(int = -m, length = totalLength) << (y+1)
	 P = BitArray(int = r, length = totalLength)
	 P = P << 1
	 for i in range(1,y+1):
	 	if P[-2:] == '0b01':
	 		P = BitArray(int = P.int + A.int, length = totalLength)
	 	elif P[-2:] == '0b10':
	 		P = BitArray(int = P.int +compliment.int, length = totalLength)
	 	P = BitArray(int=P.int >> 1,length=totalLength)
	 P = P[:-1]
	 P.int = P.int + bugbit
	 return '<h1>RESULT</h1><br><h3>decimal value: '+str(P.int)+'</br><br> binary value: '+str(P.bin)
开发者ID:akhilari7,项目名称:Cl3,代码行数:24,代码来源:booths.py

示例3: incr_pass

# 需要导入模块: from bitstring import BitArray [as 别名]
# 或者: from bitstring.BitArray import int [as 别名]
def incr_pass(board):
    new_pass = pass_count(board) + 1
    start = 2 * area + 8
    a = BitArray('0b00000000')
    a.int = new_pass
    board[start:start + 8] = a
开发者ID:GamesCrafters,项目名称:GamesmanMPI,代码行数:8,代码来源:othello_bit_new.py

示例4: incr_turn

# 需要导入模块: from bitstring import BitArray [as 别名]
# 或者: from bitstring.BitArray import int [as 别名]
def incr_turn(board):
    new_turn = (turn_count(board)) % 2 + 1
    start = 2 * area
    a = BitArray('0b00000000')
    a.int = new_turn
    board[start:start + 8] = a
开发者ID:GamesCrafters,项目名称:GamesmanMPI,代码行数:8,代码来源:othello_bit_new.py


注:本文中的bitstring.BitArray.int方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。