ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Пятница
29 марта
855088
De_User (11.07.2018 03:03 - 03:21, просмотров: 8203)
Буратино был тупой? Или это шутка такая - предварительный сдвиг в for с потерей младшего разряда? "for (v >>= 1; v; v >>= 1)" в "Reverse bits the obvious way"? https://medium.com/square-corner-blog/reversing-bits-in-c-48a772dc02d7
https://graphics.stanford.edu/~seander/bithacks.html#BitReverseObvious
Reverse bits the obvious way unsigned int v; // input bits to be reversed unsigned int r = v; // r will be reversed bits of v; first get LSB of v int s = sizeof(v) * CHAR_BIT - 1; // extra shift needed at end for (v >>= 1; v; v >>= 1) { r <<= 1; r |= v & 1; s--; } r <<= s; // shift when v's highest bits are zero
The number of bits in a character is represented by the manifest constant CHAR_BIT. The standard include file limits.h defines CHAR_BIT as 8.
Let's come together right now !