On Wed, 2019-05-01 at 10:35 -0700, blmadha...@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
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to