@technobuddha/library
Version:
A large library of useful functions
14 lines • 918 B
JavaScript
/**
* Rotates the bits of a 32-bit number to the left by a specified number of bits.
*
* @param num - The 32-bit integer to rotate.
* @param bits - The number of bits to rotate to the left.
* @returns The result of rotating `num` to the left by `bits` positions as an unsigned 32-bit integer.
* @group Binary
* @category Arithmetic
*/
export function rotl(num, bits) {
// eslint-disable-next-line no-bitwise
return ((num << bits) | (num >>> (32 - bits))) >>> 0;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm90bC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9yb3RsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7OztHQVFHO0FBQ0gsTUFBTSxVQUFVLElBQUksQ0FBQyxHQUFXLEVBQUUsSUFBWTtJQUM1QyxzQ0FBc0M7SUFDdEMsT0FBTyxDQUFDLENBQUMsR0FBRyxJQUFJLElBQUksQ0FBQyxHQUFHLENBQUMsR0FBRyxLQUFLLENBQUMsRUFBRSxHQUFHLElBQUksQ0FBQyxDQUFDLENBQUMsS0FBSyxDQUFDLENBQUM7QUFDdkQsQ0FBQyJ9