Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- template <typename BitVar>
- BitVar RotateLeft(BitVar input, unsigned char amount){
- return ((input << amount) | (input >> (sizeof(input)*CHAR_BIT - amount)));
- }
- template <typename BitVar>
- BitVar RotateRight(BitVar input, unsigned char amount){
- return ((input >> amount) | (input << (sizeof(input)*CHAR_BIT - amount)));
- }
- int main(){
- unsigned short test = 0xABCD;
- std::cout <<std::hex<< RotateLeft(test, 4) << std::endl;
- system("PAUSE>NUL");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement