📄 reverse.c
字号:
/*
** Reverse the order of the bits in an unsigned integer value.
*/
unsigned int
reverse_bits( unsigned int value )
{
unsigned int answer;
unsigned int i;
answer = 0;
/*
** Keep going as long as i is nonzero. This makes the loop
** independent of the machine's word size, hence portable.
*/
for( i = 1; i != 0; i <<= 1 ){
/*
** Shift the old answer to make room for the next
** bit; then OR in a 1 if the value's last bit is
** set; then shift the value to its next bit.
*/
answer <<= 1;
if( value & 1 )
answer |= 1;
value >>= 1;
}
return answer;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -