Easy bit reversal
37 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 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 Kommentar
Weitere Antworten (2)
Siehe auch
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!