Easy bit reversal
22 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Walter Roberson
il 22 Feb 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 Commento
Più risposte (2)
Vedere anche
Categorie
Scopri di più su Get Started with MATLAB in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!