Logical left shift and truncate bit length
6 ビュー (過去 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?
0 件のコメント
回答 (1 件)
Adam
2017 年 2 月 9 日
Just throw away the first element of the array e.g.
res = dec2bin( bitshift( 135, 1 ) );
res = res( 2:end );
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Numeric Types についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!