Jcd.BitManipulation

A bit manipulation readability enhancement library.

Jcd.BitManipulation

Jcd.BitManipulation.Algorithms.ByteAlgorithmsExtensions

ByteAlgorithmsExtensions.RotateRight(this byte, int) Method

Performs a bitwise right rotation on a number.

public static byte RotateRight(this byte number, int count);

Parameters

number System.Byte

The number to rotate

count System.Int32

the number of bits to rotate

Returns

System.Byte The rotated value.

Example

Examples

byte b = 0b11110000;
var b2 = b.RotateRight(3); // b2 = 0b00011110
var b3 = b.RotateRight(4); // b3 = 0b00001111
var b4 = b.RotateRight(5); // b4 = 0b10000111
var b5 = b.RotateRight(6); // b5 = 0b11000011
var b6 = b.RotateRight(7); // b6 = 0b11100001
var b7 = b.RotateRight(8); // b7 = 0b11110000