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

On Wed, 2019-05-01 at 10:35 -0700, blmadhavan at gmail.com wrote: > 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. >From the Matlab doc: ' intout = bitshift(A,k) intout = bitshift(A,k,assumedtype) Description example intout = bitshift(A,k) returns A shifted to the left by k bits, equivalent to multiplying by 2k. Negative values of k correspond to shifting bits right or dividing by 2|k| and rounding to the nearest integer towards negative infinity. Any overflow bits are truncated.?' So the equivalent would be: >>> typeBits =?FCF >> 9 Cheers Brian

- Prev by Date:
**PYTHON equivalents of BITAND and BITSHIFT of MATLAB** - Next by Date:
**A newbie question about using tix** - Previous by thread:
**PYTHON equivalents of BITAND and BITSHIFT of MATLAB** - Next by thread:
**PYTHON equivalents of BITAND and BITSHIFT of MATLAB** - Index(es):