osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PYTHON equivalents of BITAND and BITSHIFT of MATLAB


Hi,

I have the following line from a MATLAB program with FCF (format: UInt_16) as input:

ftype = bitand(FCF, 7)
typeBits = bitshift(FCF, -9)
subtype = bitand(typeBits, 7)

I wrote the following in Python for the above commands:

ftype = FCF & 7
typeBits = FCF << -9             ------> Is this correct or FCF >> -9?
subtype = typeBits & 7
 
Can someone help me write the equivalent command in PYTHON?

Look forward to your suggestions.