예제 #1
0
파일: packets.py 프로젝트: imoyer/pygestalt
 def _decode_(self, decodePacket):
     """Decodes the provided packet snippet into a signed integer of length self.size.
     
     decodePacket -- the ordered list of bytes to be converted into an unsigned integer.
     """
     twosComplementInteger = utilities.bytesToUnsignedInteger(decodePacket)
     return utilities.twosComplementToSignedInteger(twosComplementInteger, self.bitSize)
예제 #2
0
파일: packets.py 프로젝트: imoyer/pygestalt
 def _decode_(self, decodePacket):
     """Decodes the provided packet snippet into a fixed point signed decimal.
     
     decodePacket -- the ordered list of bytes to be converted into a fixed point decimal.
     """
     twosComplementRepresentation = utilities.bytesToUnsignedInteger(decodePacket)
     twosComplementRepresentation = twosComplementRepresentation&(2**(self.bitSize) - 1) #mask off any unwanted bits
     if self.integerBits > 0: #signed value
         signedInteger = utilities.twosComplementToSignedInteger(twosComplementRepresentation, self.bitSize)
     else:   #no integer bits, unsigned value
         signedInteger = twosComplementRepresentation
     bitShiftedValue = float(signedInteger)/(2**self.fractionalBits)
     return bitShiftedValue