本文整理汇总了Python中convert.Convert.decimal_to_binary方法的典型用法代码示例。如果您正苦于以下问题:Python Convert.decimal_to_binary方法的具体用法?Python Convert.decimal_to_binary怎么用?Python Convert.decimal_to_binary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类convert.Convert
的用法示例。
在下文中一共展示了Convert.decimal_to_binary方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_binary_code
# 需要导入模块: from convert import Convert [as 别名]
# 或者: from convert.Convert import decimal_to_binary [as 别名]
def get_binary_code(self,operator):
code = self.operations[operator]
c = Convert()
dec_code = c.to_decimal(code+"H")
binary = c.decimal_to_binary(int(dec_code),8)
binary = binary[0:-2]
del c
return binary
示例2: operations_code
# 需要导入模块: from convert import Convert [as 别名]
# 或者: from convert.Convert import decimal_to_binary [as 别名]
def operations_code(self,operator,m,is_index):
r = Register("T")
c = Convert()
op = self.operations[operator]
op = op+"H"
op = c.to_decimal(op)
op = int(op)
binary = c.decimal_to_binary(op,24)
binary = c.shift_binary_left(binary,16)
if is_index:
binary = c.mask_or(binary,"000000001000000000000000")
m = c.to_decimal(m)
m = int(m)
m = c.decimal_to_binary(m,24)
binary = c.mask_or(binary,m)
val = int(binary,2)
val = c.decimal_to_hexadecimal(val)
val = r.filter_number(val)
val = r.adjust_bytes(val,6,False)
del r
del c
return val
示例3: get_address_tarjet
# 需要导入模块: from convert import Convert [as 别名]
# 或者: from convert.Convert import decimal_to_binary [as 别名]
def get_address_tarjet(self, value):
c = Convert()
addressing = value[0] + "H"
addressing = int(c.to_decimal(addressing))
val = value
bina = c.decimal_to_binary(addressing, 4)
bina = c.mask_and(bina, "1000")
if bina == "1000":
val = self.hex.subs(value, "8000H")
x = self.get_x_value()
val = self.hex.plus(val, x)
val = self.reg.filter_number(val)
return val