Table of Contents

Class BitUtility

Namespace
Apache.Arrow
Assembly
Apache.Arrow.dll
public static class BitUtility
Inheritance
BitUtility
Inherited Members

Methods

ByteCount(int)

Calculates the number of bytes required to store n bits.

public static int ByteCount(int n)

Parameters

n int

Number of bits

Returns

int

Number of bytes

ClearBit(Span<byte>, int)

public static void ClearBit(Span<byte> data, int index)

Parameters

data Span<byte>
index int

CountBits(ReadOnlySpan<byte>)

Counts the number of set bits in a span of bytes.

public static int CountBits(ReadOnlySpan<byte> data)

Parameters

data ReadOnlySpan<byte>

Span to count bits.

Returns

int

Count of set (one) bits.

CountBits(ReadOnlySpan<byte>, int)

Counts the number of set bits in a span of bytes starting at a specific bit index.

public static int CountBits(ReadOnlySpan<byte> data, int index)

Parameters

data ReadOnlySpan<byte>

Span to count bits.

index int

Bit index to start counting from.

Returns

int

Count of set (one) bits.

CountBits(ReadOnlySpan<byte>, int, int)

Counts the number of set bits in a span of bytes starting at a specific bit index, and limiting to a certain number of bits in the span.

public static int CountBits(ReadOnlySpan<byte> data, int index, int length)

Parameters

data ReadOnlySpan<byte>

Span to count bits.

index int

Bit index to start counting from.

length int

Maximum of bits in the span to consider.

Returns

int

Count of set (one) bits.

GetBit(byte, int)

public static bool GetBit(byte data, int index)

Parameters

data byte
index int

Returns

bool

GetBit(ReadOnlySpan<byte>, int)

public static bool GetBit(ReadOnlySpan<byte> data, int index)

Parameters

data ReadOnlySpan<byte>
index int

Returns

bool

RoundUpToMultipleOf64(long)

Rounds an integer to the nearest multiple of 64.

public static long RoundUpToMultipleOf64(long n)

Parameters

n long

Integer to round.

Returns

long

Integer rounded to the nearest multiple of 64.

RoundUpToMultipleOf8(long)

Rounds an integer to the nearest multiple of 8.

public static long RoundUpToMultipleOf8(long n)

Parameters

n long

Integer to round.

Returns

long

Integer rounded to the nearest multiple of 8.

RoundUpToMultiplePowerOfTwo(long, int)

Rounds an integer up to the nearest multiple of factor, where factor must be a power of two.

This function does not throw when the factor is not a power of two.

public static long RoundUpToMultiplePowerOfTwo(long n, int factor)

Parameters

n long

Integer to round up.

factor int

Power of two factor to round up to.

Returns

long

Integer rounded up to the nearest power of two.

SetBit(Span<byte>, int)

public static void SetBit(Span<byte> data, int index)

Parameters

data Span<byte>
index int

SetBit(Span<byte>, int, bool)

public static void SetBit(Span<byte> data, int index, bool value)

Parameters

data Span<byte>
index int
value bool

ToggleBit(Span<byte>, int)

public static void ToggleBit(Span<byte> data, int index)

Parameters

data Span<byte>
index int