GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — python/Data Formatter/bitFields_old2.py at master · LeoJr2015/python Expand file tree/ Copy pathbitFields_old2.pyMore file actions 38 lines (32 loc) · 1.01 KB / Copy pathbitFields_old2.pyFile metadata and controls38 lines (32 loc) · 1.01 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 import csv def splitBinary(hex,size=8): lst = [] #Round the size up to a multiple of 8 if (size % 8): size = size + (8 - size % 8) binary = bin(int(hex,16))[2:] for char in binary: lst.append(char) while (len(lst)<size): lst = ['0'] + lst return lst class bitField: def __init__(self,file,type): self.bits = [] self.bits = type self.data = [] def get_r(self): for i in range(len(self.bits)): print "%10s | %5s" % (self.bits[i],self.data[i]) def add_data(self,data): size = (len(data)*2) if size < 8: size = 8 self.data = splitBinary(data,(len(data)*2)) while (len(self.bits)<len(self.data)): self.bits = ['#'] + self.bits if __name__ == "__main__": field = bitField('bitFields.csv',['Bit 7','Bit 6','Bit 5','Bit 4','Bit 3','Bit 2','Bit 1','Bit 0']) field.add_data('A') field.get_r() #print splitBinary("A") |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |