📄 rolror.cpp
字号:
//: C03:Rolror.cpp {O}
// From Thinking in C++, 2nd Edition
// at http://www.BruceEckel.com
// (c) Bruce Eckel 1999
// Copyright notice in Copyright.txt
// Perform left and right rotations
unsigned char ROL(unsigned char val) {
int highbit;
if(val & 0x80) // 0x80 is the high bit only
highbit = 1;
else
highbit = 0;
val <<= 1; // Left shift (bottom bit becomes 0)
val |= highbit; // Rotate the high bit onto the bottom
return val; // This becomes the function value
}
unsigned char ROR(unsigned char val) {
int lowbit;
if(val & 1) // Check the low bit
lowbit = 1;
else
lowbit = 0;
val >>= 1; // Right shift by one position
val |= (lowbit << 7); // Rotate the low bit onto the top
return val;
} ///:~
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -