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

Hello Brian, Thanks for your suggestion. Which is correct for MATLAB command: typeBits = FCF << -9? typeBits = FCF >> 9 or typeBits = FCF >> -9 I mean to ask if it should be -9 or +9? Thanks in advance Madhavan On Wednesday, May 1, 2019 at 11:22:10 PM UTC+5:30, Brian Oney wrote: > 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:
**Populating a timetable with subjects** - Next by Date:
**Checking network input processing by Python for a multi-threaded server** - Previous by thread:
**PYTHON equivalents of BITAND and BITSHIFT of MATLAB** - Next by thread:
**PYTHON equivalents of BITAND and BITSHIFT of MATLAB** - Index(es):