Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Initial --> 1000 0011 0100 0010
- Final --> 1010 0000 1101 0000
- __asm
- {
- rol number,1
- }
- template <typename INT>
- T rol(T val) {
- return (val << 1) | (val >> (sizeof(T)*CHAR_BIT-1));
- }
- unsigned ror(unsigned x, int L, int N)
- {
- unsigned lsbs = x & ((1 << L) - 1);
- return (x >> L) | (lsbs << (N-L));
- }
- #include <bitset>
- #include <iostream>
- template <std::size_t N>
- inline void
- rotate(std::bitset<N>& b, unsigned m)
- {
- b = b << m | b >> (N-m);
- }
- int main()
- {
- std::bitset<8> b(15);
- std::cout << b << 'n';
- rotate(b, 2);
- std::cout << b << 'n';
- return 0;
- }
- #include <bitset>
- #include <iostream>
- template <std::size_t N>
- inline void
- rotate(std::bitset<N>& b, unsigned m)
- {
- b = b << m | b >> (N-m);
- }
- int main()
- {
- std::bitset<8> b(15);
- std::cout << b << 'n';
- rotate(b, 2);
- std::cout << b << 'n';
- return 0;
- }
- #include <bitset>
- #include <iostream>
- template <std::size_t N>
- inline void
- rotate(std::bitset<N>& b, unsigned m)
- {
- b = b << m | b >> (N-m);
- }
- int main()
- {
- std::bitset<8> b(15);
- std::cout << b << 'n';
- rotate(b, 2);
- std::cout << b << 'n';
- return 0;
- }
- #include <bitset>
- #include <iostream>
- template <std::size_t N>
- inline void
- rotate(std::bitset<N>& b, unsigned m)
- {
- b = b << m | b >> (N-m);
- }
- int main()
- {
- std::bitset<8> b(15);
- std::cout << b << 'n';
- rotate(b, 2);
- std::cout << b << 'n';
- return 0;
- }
- #include <bitset>
- #include <iostream>
- template <std::size_t N>
- inline void
- rotate(std::bitset<N>& b, unsigned m)
- {
- b = b << m | b >> (N-m);
- }
- int main()
- {
- std::bitset<8> b(15);
- std::cout << b << 'n';
- rotate(b, 2);
- std::cout << b << 'n';
- return 0;
- }
- unsigned int rotate_right(unsigned int x)
- {
- return (x>>1 | (x&1?0x80000000:0))
- }
- unsigned short rotate_right(unsigned short x) { /* etc. */ }
- x=(x>>1 | x<<7);
- #define ROTATE_RIGHT(x) ( (x>>1) | (x&1?0x8000:0) )
Add Comment
Please, Sign In to add comment