BitUtility.h 402 B

1234567891011121314151617181920
  1. #pragma once
  2. namespace Javelin {
  3. class BitUtility {
  4. public:
  5. static bool IsPowerOf2(unsigned int x) {
  6. return (x & (x - 1)) == 0;
  7. }
  8. static unsigned int RotateRight(unsigned int value, unsigned int shift) {
  9. if ((shift &= sizeof(value) * 8 - 1) == 0) {
  10. return value;
  11. }
  12. return (value >> shift) | (value << (sizeof(value) * 8 - shift));
  13. }
  14. };
  15. }