This question already has answers here:
Closed 2 years ago.
Best practices for circular shift (rotate) operations in C++
(16个答案)
我正在尝试在AMD64下执行左循环移位(rol)。
与MSVC提供的内核(rotl64)类似的内核是什么?

最佳答案

#include <stdint.h>

inline uint64_t rotl64 ( uint64_t x, int8_t r )
{
  return (x << r) | (x >> (64 - r));
}

07-27 19:23