필터 지우기
필터 지우기

Logical left shift and truncate bit length

조회 수: 8 (최근 30일)
fiona rozario
fiona rozario 2017년 2월 9일
답변: Adam 2017년 2월 9일
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