Changeset 922:fcbc41076194 for src


Ignore:
Timestamp:
04/27/19 12:07:59 (5 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Using integer division where necessary (re #347).

Location:
src/mlx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/fsuipc.py

    r921 r922  
    14101410
    14111411        numNotchesM1 = len(self._flapsNotches) - 1
    1412         flapsIncrement = 16383 / numNotchesM1
     1412        flapsIncrement = 16383 // numNotchesM1
    14131413        flapsControl = data[self._monidx_flapsControl]
    1414         flapsIndex = flapsControl / flapsIncrement
     1414        flapsIndex = flapsControl // flapsIncrement
    14151415        if flapsIndex < numNotchesM1:
    14161416            if (flapsControl - (flapsIndex*flapsIncrement) >
  • src/mlx/pyuipc_sim.py

    r919 r922  
    184184    def _readBCD(value):
    185185        """Convert the given value into BCD format."""
    186         bcd = (value/1000) % 10
     186        bcd = (value//1000) % 10
    187187        bcd <<= 4
    188         bcd |= (value/100) % 10
     188        bcd |= (value//100) % 10
    189189        bcd <<= 4
    190         bcd |= (value/10) % 10
     190        bcd |= (value//10) % 10
    191191        bcd <<= 4
    192192        bcd |= value % 10
     
    360360            return int(index * flapsIncrement +
    361361                       (self.flapsControl-self.flapsNotches[index]) *
    362                        flapsIncrement /
     362                       flapsIncrement //
    363363                       (self.flapsNotches[index+1] - self.flapsNotches[index]))
    364364
     
    542542        elif offset>=0x1400 and offset<=0x1f40 and \
    543543             ((offset-0x1400)%48)==0: # Payload
    544             return self.payload[ (offset - 0x1400) / 48 ]
     544            return self.payload[ (offset - 0x1400) // 48 ]
    545545        elif offset==0x2000:       # Engine #1 N1
    546546            return self.n1[self.ENGINE_1]
     
    568568        elif offset>=0x3210 and offset<0x3210+Values.HOTKEY_SIZE*4:
    569569            tableOffset = offset - 0x3210
    570             hotkeyIndex = tableOffset / 4
     570            hotkeyIndex = tableOffset // 4
    571571            index = tableOffset % 4
    572572            if type=="b" or type=="c":
     
    602602            return self._getFlapsControl()
    603603        elif offset==0x3bfa:       # Flaps increment
    604             return 16383 / (len(self.flapsNotches)-1)
     604            return 16383 // (len(self.flapsNotches)-1)
    605605        elif offset==0x3bfc:       # ZFW
    606606            return int(self.zfw * 256.0 * const.KGSTOLB)
     
    758758        elif offset==0x0bd0:       # Spoilers
    759759            self.spoilters = 0 if value==0 \
    760                              else (value - 4800) / (16383 - 4800)
     760                             else (value - 4800) // (16383 - 4800)
    761761        elif offset==0x0bdc:       # Flaps control
    762762            numNotchesM1 = len(self.flapsNotches) - 1
     
    768768                self.flapsControl = self.flapsNotches[index]
    769769                self.flapsControl += (value - index * flapsIncrement) * \
    770                     (self.flapsNotches[index+1] - self.flapsNotches[index]) / \
     770                    (self.flapsNotches[index+1] - self.flapsNotches[index]) // \
    771771                    flapsIncrement
    772772        elif offset==0x0be0 or offset==0x0be4:    # Flaps left and  right
     
    816816        elif offset>=0x1400 and offset<=0x1f40 and \
    817817             ((offset-0x1400)%48)==0: # Payload
    818             self.payload[ (offset - 0x1400) / 48 ] = value
     818            self.payload[ (offset - 0x1400) // 48 ] = value
    819819        elif offset==0x2000:       # Engine #1 N1
    820820            self.n1[self.ENGINE_1] = value
     
    840840        elif offset>=0x3210 and offset<0x3210+Values.HOTKEY_SIZE*4:
    841841            tableOffset = offset - 0x3210
    842             hotkeyIndex = tableOffset / 4
     842            hotkeyIndex = tableOffset // 4
    843843            index = tableOffset % 4
    844844            if type=="b" or type=="c":
Note: See TracChangeset for help on using the changeset viewer.