Guest User

Untitled

a guest
Nov 24th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. unsigned long long rotateLeft( unsigned long long bs )
  2. {
  3. return ( ( bs & 0x0000000000001111 ) << 48 ) |
  4. ( ( bs & 0x0000000000002222 ) << 31 ) |
  5. ( ( bs & 0x0000000000004444 ) << 14 ) |
  6. ( ( bs & 0x0000000000008888 ) >> 3 ) |
  7. ( ( bs & 0x0000000011110000 ) << 33 ) |
  8. ( ( bs & 0x0000000022220000 ) << 16 ) |
  9. ( ( bs & 0x0000000044440000 ) >> 1 ) |
  10. ( ( bs & 0x0000000088880000 ) >> 18 ) |
  11. ( ( bs & 0x0000111100000000 ) << 18 ) |
  12. ( ( bs & 0x0000222200000000 ) << 1 ) |
  13. ( ( bs & 0x0000444400000000 ) >> 16 ) |
  14. ( ( bs & 0x0000888800000000 ) >> 33 ) |
  15. ( ( bs & 0x1111000000000000 ) << 3 ) |
  16. ( ( bs & 0x2222000000000000 ) >> 14 ) |
  17. ( ( bs & 0x4444000000000000 ) >> 31 ) |
  18. ( ( bs & 0x8888000000000000 ) >> 48 );
  19. }
  20.  
  21. unsigned long long rotateLeft( unsigned long long bs )
  22. {
  23. //mirror in diagonal plane (x=z?)
  24. bs = ( ( bs & 0x0000000000008888 ) << 45 ) | ( ( bs & 0x1111000000000000 ) >> 45 ) |
  25. ( ( bs & 0x0000000088884444 ) << 30 ) | ( ( bs & 0x2222111100000000 ) >> 30 ) |
  26. ( ( bs & 0x0000888844442222 ) << 15 ) | ( ( bs & 0x4444222211110000 ) >> 15 ) |
  27. ( bs & 0x8888444422221111 );
  28. //mirror in vertical plane (xy?)
  29. //I do apologize for not knowing the correct terminology.
  30. bs = ( ( bs & 0x00000000ffffffff ) << 32 ) | ( ( bs & 0xffffffff00000000 ) >> 32 );
  31. return ( ( bs & 0x0000ffff0000ffff ) << 16 ) | ( ( bs & 0xffff0000ffff0000 ) >> 16 ) |
  32. }
Add Comment
Please, Sign In to add comment