Logical left shift and truncate bit length

13 次查看(过去 30 天)
I need to convert a decimal number to binary and perform a left shift operation.
Ex: If the decimal is 135, its binary is '1000 0111'. After left shift I need '0000 1110'. The bitshift() is giving '1000 01110'. How can I truncate this to remove the msb?

回答(1 个)

Adam
Adam 2017-2-9
Just throw away the first element of the array e.g.
res = dec2bin( bitshift( 135, 1 ) );
res = res( 2:end );

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by