Borrar filtros
Borrar filtros

Logical left shift and truncate bit length

8 visualizaciones (últimos 30 días)
fiona rozario
fiona rozario el 9 de Feb. de 2017
Respondida: Adam el 9 de Feb. de 2017
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?

Respuestas (1)

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

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by