Class BitOperations
- Namespace
- SunamoShared.Helpers.DataTypes
- Assembly
- SunamoShared.dll
Provides low-level bit manipulation operations for reading, writing, and copying bits within byte arrays and ulong values.
public static class BitOperations
- Inheritance
-
BitOperations
- Inherited Members
Methods
CopyBlock(byte[], int, int)
Copies a block of bits from the source byte array starting at the specified bit offset.
public static byte[] CopyBlock(byte[] bytes, int offset, int length)
Parameters
bytesbyte[]Source byte array.
offsetintBit offset to start copying from.
lengthintNumber of bits to copy.
Returns
- byte[]
CopyBytes(byte[], int, byte[])
Copies source bytes into the destination byte array at the specified offset.
public static void CopyBytes(byte[] destination, int destinationOffset, byte[] source)
Parameters
destinationbyte[]Destination byte array.
destinationOffsetintByte offset in the destination array.
sourcebyte[]Source byte array to copy from.
Read(byte[], ref int, int)
Reads the specified number of bits from a byte array at the given bit offset.
public static int Read(byte[] bytes, ref int offset, int length)
Parameters
bytesbyte[]Source byte array.
offsetintReference to the current bit offset, updated after reading.
lengthintNumber of bits to read.
Returns
Read(ref ulong, int)
Reads the specified number of bits from the high end of a ulong value and shifts the value left.
public static int Read(ref ulong bits, int length)
Parameters
Returns
Write(ref ulong, int, int)
Writes the specified number of bits to the low end of a ulong value, shifting existing bits left.
public static void Write(ref ulong bits, int length, int value)