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


Python Convert.to_decimal方法代码示例

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


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

示例1: get_len_program

# 需要导入模块: from convert import Convert [as 别名]
# 或者: from convert.Convert import to_decimal [as 别名]
 def get_len_program(self):
     c = Convert()
     x = self.bloques[-1]
     ini = self.bloques[0]
     val = c.to_decimal(x.get_load_dir())
     val_len = c.to_decimal(x.length)
     val_ini = c.to_decimal(ini.get_load_dir())
     val = val + val_len - val_ini
     val = c.decimal_to_hexadecimal(val)
     return val
开发者ID:Juanirow,项目名称:esic,代码行数:12,代码来源:bloque.py

示例2: is_type_c

# 需要导入模块: from convert import Convert [as 别名]
# 或者: from convert.Convert import to_decimal [as 别名]
 def is_type_c(self,desp):
     c = Convert()
     desp = c.to_decimal(desp)
     del c
     if desp < 4096:
         return True
     return False
开发者ID:Juanirow,项目名称:esic,代码行数:9,代码来源:step2.py

示例3: relative_base

# 需要导入模块: from convert import Convert [as 别名]
# 或者: from convert.Convert import to_decimal [as 别名]
 def relative_base(self,arg):
     hex = Hexadecimal()
     c = Convert()        
     res = hex.subs(arg,self.base)
     res_dec = c.to_decimal(res)
     if res_dec >= 0 and res_dec <= 4095:
         return res
     return None
开发者ID:Juanirow,项目名称:esic,代码行数:10,代码来源:step2.py

示例4: get_binary_code

# 需要导入模块: from convert import Convert [as 别名]
# 或者: from convert.Convert import to_decimal [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
开发者ID:Juanirow,项目名称:esic,代码行数:10,代码来源:step2.py

示例5: charge_text

# 需要导入模块: from convert import Convert [as 别名]
# 或者: from convert.Convert import to_decimal [as 别名]
 def charge_text(self):
     c = Convert()
     for r in self.registers:
         string = r[9:]
         index = 0
         init = r[1:7]
         col_start = init[-1] + "H"
         col = int(c.to_decimal(col_start) + 1)
         res = self.hex.subs(init[:-1], self.init[:-1])
         dec_res = int(c.to_decimal(res))
         while index < len(string):
             byte = string[index : index + 2]
             item = QtGui.QTableWidgetItem(byte)
             self.window.tableWidget.setItem(dec_res, col, item)
             index += 2
             col = (col + 1) % 17
             if col == 0:
                 col = 1
                 dec_res += 1
开发者ID:Juanirow,项目名称:esic,代码行数:21,代码来源:Cargador.py

示例6: make_M_modificado

# 需要导入模块: from convert import Convert [as 别名]
# 或者: from convert.Convert import to_decimal [as 别名]
 def make_M_modificado(self,obj_code,cp_num):
     c = Convert()
     cp_num = c.to_decimal(cp_num)
     cp_num = c.decimal_to_hexadecimal(cp_num)        
     dir= self.filter_number(cp_num)
     dir = self.adjust_bytes(dir,6,False)
     edit_bytes = obj_code
     len_bytes = len(edit_bytes)
     len_bytes = self.adjust_bytes(str(len_bytes),2,False)
     register = "M" + str(dir) + str(len_bytes)+"+"+self.name
     return register
开发者ID:Juanirow,项目名称:esic,代码行数:13,代码来源:register.py

示例7: operations_code

# 需要导入模块: from convert import Convert [as 别名]
# 或者: from convert.Convert import to_decimal [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
开发者ID:Juanirow,项目名称:esic,代码行数:24,代码来源:step2.py

示例8: get_address_tarjet

# 需要导入模块: from convert import Convert [as 别名]
# 或者: from convert.Convert import to_decimal [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
开发者ID:Juanirow,项目名称:esic,代码行数:15,代码来源:Cargador.py

示例9: is_relative_cp

# 需要导入模块: from convert import Convert [as 别名]
# 或者: from convert.Convert import to_decimal [as 别名]
 def is_relative_cp(self,cp,arg):
     hex = Hexadecimal()
     c = Convert()        
     res_hex = hex.subs_minus(arg,cp)
     sign = res_hex[1]
     res_hex = res_hex[0]
     res = int(c.to_decimal(res_hex))
     if sign == "-":
         res = (res ^ 4095)+1
         res = res * -1 
     if res <= 2047 and res >= -2048:
         return c.exp_to_hexadecimal(res)
     else: 
         return None
开发者ID:Juanirow,项目名称:esic,代码行数:16,代码来源:step2.py

示例10: charge_header

# 需要导入模块: from convert import Convert [as 别名]
# 或者: from convert.Convert import to_decimal [as 别名]
 def charge_header(self):
     init = self.header[7:13]
     self.init = init
     length = self.header[13:]
     self.end_program = self.hex.plus(init, length)
     star_rows = length[:-1]
     index = init[:-1]
     num_rows = star_rows + "H"
     c = Convert()
     num_rows = int(c.to_decimal(num_rows))
     self.window.tableWidget.setRowCount(num_rows + 1)
     it = 0
     while it <= num_rows:
         dir = index + "0H"
         r = Register("T")
         dir = r.adjust_bytes(dir, 6, False)
         item = QtGui.QTableWidgetItem(dir)
         self.window.tableWidget.setItem(it, 0, item)
         it += 1
         index = self.hex.plus(index, "1H")[:-1]
开发者ID:Juanirow,项目名称:esic,代码行数:22,代码来源:Cargador.py

示例11: Cargadorx

# 需要导入模块: from convert import Convert [as 别名]
# 或者: from convert.Convert import to_decimal [as 别名]
class Cargadorx():
    def __init__(self,window):
        self.window = window
        self.tabse = Tabse()
        self.lonsc = "0H"
        self.dirsc = "0H"
        self.dirprog = "0H"
        self.direj = "0H"
        self.hexa = Hexadecimal()
        self.convert = Convert()
        self.register = Register("A")
        self.error_indefinido = False
        self.error_duplicado = False

    def show_error(self,msg):
        ##QtGui.QMessageBox.about(self.window,"Error",msg)
        self.window.textEdit_Actions.setText(msg)

    def load_file_name(self,list_obj,dirprog):
        val_int = self.convert.to_decimal(dirprog)
        self.dirprog = self.convert.decimal_to_hexadecimal(val_int)
        self.dirprog = self.register.adjust_bytes(self.dirprog,6,False)+"H"
        self.dirsc = self.dirprog
        self.step_1(list_obj)
        if not self.error_duplicado:
            self.create_memory()
            self.dirsc = self.dirprog
            self.direj = self.dirprog
            self.step_2(list_obj)
            self.init_empty_rows()
            self.tabse.print_tabse()
            if self.error_indefinido:
                self.show_error("Error en simbolo indefinido")
        else:
            self.show_error("Error simbolo duplicado")



    def step_1(self,list_obj):
        for list_n in list_obj:
            for n in list_n:
                if len(n) > 0:
                    if n[0] == "H":
                        self.step_h(n,1)
                    elif n[0] == "D":
                        self.step_1_d(n)
            self.dirsc = self.hexa.plus(self.dirsc,self.lonsc)

    def step_h(self,n,step):
        name = n[1:7]
        name = name.strip()
        self.lonsc = n[13:]+"H"
        if step == 1:
            if not self.tabse.exist_node(name):
                self.tabse.insert_section(name,self.dirsc,self.lonsc)
            else:
                ##print name
                self.error_duplicado = True

    def step_1_d(self,n):
        num = (len(n)-1)/12
        it = 0
        # print "num",num,len(n)
        while it < num:
            index1 = (it * 12)+1
            index2 = index1 + 6
            index3 = index2 + 6
            name = n[index1:index2].strip()
            #print "name",name 
            if index3 >= len(n):
                len_r = n[index2:]+"H"
            else:
                len_r = n[index2:index3]+"H"
            if not self.tabse.exist_node(name):
                val = self.hexa.plus(len_r,self.dirsc)
                self.tabse.insert_variable(name,val)
            else:
                print "error",name
                self.error_duplicado = True
            it += 1

    def step_2(self,list_obj):
        for list_n in list_obj:
            for n in list_n:
                if len(n) > 0:
                    if n[0] == "H":
                        self.step_h(n,2)
                    elif n[0] == "T":
                        self.charge_obj_code(n)
                    elif n[0] == "M":
                        self.change_m_register(n)
                    elif n[0] == "E":
                        self.reg_e(n)
            self.dirsc = self.hexa.plus(self.dirsc,self.lonsc) 

    def reg_e(self,r):
        if len(r) > 1:
            val = r[1:] + "H"
            self.direj = self.hexa.plus(self.dirsc,val)

#.........这里部分代码省略.........
开发者ID:Juanirow,项目名称:esic,代码行数:103,代码来源:Cargadorx.py

示例12: Simuladorx

# 需要导入模块: from convert import Convert [as 别名]
# 或者: from convert.Convert import to_decimal [as 别名]

#.........这里部分代码省略.........

	def get_register(self,reg_num):
		item = self.window.tableWidget_2.item(reg_num,0)
		return str(item.text())

	def carga(self,list_obj,dirprog):
		self.cargador = Cargadorx(self.window)
		self.cargador.load_file_name(list_obj,dirprog)
		cp = self.cargador.direj
		self.set_register(self.REG_CP,cp)
		self.show_next_instr()
		self.end_program = self.cargador.dirsc
		if self.cargador.error_duplicado:
			QtGui.QMessageBox.about(self,"Error","Error simbolo duplicado")
		elif self.cargador.error_indefinido:
			QtGui.QMessageBox.about(self,"Error","Error simbolo indefinido")


	def increment_cp(self,num):
		num_hexa = self.convert.decimal_to_hexadecimal(num)
		cp = self.get_register(self.REG_CP)
		res = self.hexa.plus(num_hexa,cp)
		self.set_register(self.REG_CP,res)

	def show_next_instr(self):
		op = self.get_operation()
		self.window.label_sig.setText(op[1])
	
	def get_operation(self):
		cp = self.get_register(self.REG_CP)
		value = self.get_data_form_mem(cp,1)
		val = value[0]
		val2 = value[1]
		val_d = int(self.convert.to_decimal(val2+"H"))
		val_d = val_d & 12
		value = val + self.convert.decimal_to_hexadecimal(str(val_d))[:-1]
		tip = "Error"
		op = self.operations_1.get(value,"Error")
		if not op == "Error":
			tip = "1"
		else:
			op = self.operations_2.get(value,"Error")
			if not op == "Error":
				tip = "2"
			else:
				op = self.operations_3.get(value,"Error")
				if not op == "Error":
					tip = "3"
		return [value,op,tip]
		
	##regresa los datos de una localidad y las licalidades 
	#siguientes 
	# @param localidad  donde se obtendra el dato
	# @param num_loc cuantas localidades siguientes accedera 
	def get_data_form_mem(self,location,num_loc):
		loc = self.register.filter_number(location)
		row = self.get_row_index(loc)
		col = self.get_column_index(loc)
		data = ""
		it = col
		count = 0
		while count < num_loc:
			item = self.window.tableWidget.item(row,it)
			data += str(item.text())
			it = (it+1)%17
			if it == 0:
开发者ID:Juanirow,项目名称:esic,代码行数:70,代码来源:simuladorx.py

示例13: get_column_index

# 需要导入模块: from convert import Convert [as 别名]
# 或者: from convert.Convert import to_decimal [as 别名]
 def get_column_index(self, value):
     c = Convert()
     index = str(value[-1]) + "H"
     index = c.to_decimal(index)
     del c
     return index + 1
开发者ID:Juanirow,项目名称:esic,代码行数:8,代码来源:Cargador.py


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