Easy bit reversal
35 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I need a function to reverse the bits of an int. I see I can flip bytes around, but that doesn't reverse the bit order. Any easy ideas? Thanks.
0 comentarios
Respuesta aceptada
Walter Roberson
el 22 de Feb. de 2012
sum(uint32(bitset(0,1:32,bitget(uint32(X), 32:-1:1))))
(yes, there are other ways, some of them quite short but not necessarily efficient.)
1 comentario
Más respuestas (2)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!