summaryrefslogtreecommitdiff
path: root/thirdparty/pvrtccompressor/BitUtility.h
blob: 588ff3e8926ec6027bfdc9bafe3b87a2dcf19e78 (plain)
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));
    }
};

}