Table of Contents

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

bytes byte[]

Source byte array.

offset int

Bit offset to start copying from.

length int

Number 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

destination byte[]

Destination byte array.

destinationOffset int

Byte offset in the destination array.

source byte[]

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

bytes byte[]

Source byte array.

offset int

Reference to the current bit offset, updated after reading.

length int

Number of bits to read.

Returns

int

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

bits ulong

Reference to the ulong value to read from.

length int

Number of bits to read.

Returns

int

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)

Parameters

bits ulong

Reference to the ulong value to write to.

length int

Number of bits to write.

value int

The value to write.