File: BitUtility.h

package info (click to toggle)
godot3 3.6.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 229,256 kB
  • sloc: cpp: 853,371; xml: 80,316; ansic: 49,285; cs: 14,559; python: 11,794; java: 9,714; javascript: 4,654; pascal: 1,176; sh: 884; objc: 628; makefile: 182; perl: 2
file content (19 lines) | stat: -rw-r--r-- 402 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#pragma once

namespace Javelin {

class BitUtility {
public:
    static bool IsPowerOf2(unsigned int x) {
        return (x & (x - 1)) == 0;
    }

    static unsigned int RotateRight(unsigned int value, unsigned int shift) {
        if ((shift &= sizeof(value) * 8 - 1) == 0) {
            return value;
        }
        return (value >> shift) | (value << (sizeof(value) * 8 - shift));
    }
};

}