Table of Contents

Class Bitmask

Namespace
ArcanaDevelopment.adTempus.Shared
Assembly
ArcanaDevelopment.adTempus.Shared.dll
public static class Bitmask
Inheritance
object
Bitmask

Methods

CreateBitmask(params int[])

Gets a bitmask with a specified bit set. BitMask returns a value in which only the specified bits are set (i.e., is 1).

List of bits to set. Each value must be in the range 0-31. BitMask(0)=1 (binary 00000001) BitMask(1)=2 (binary 00000010) BitMask(2)=4 (binary 00000100)
public static int CreateBitmask(params int[] bits)

Parameters

NameTypeDescription
bits int[]

Returns

int

HasBit(int, int)

Tests whether a specified bit is set in a bitmask.

public static bool HasBit(int val, int bit)

Parameters

NameTypeDescription
val int

The value to test.

bit int

The bit (0 - 31) to test.

Returns

bool

HasFlags(int, int)

Tests whether the specified value is included in a bitmask.

public static bool HasFlags(int val, int mask)

Parameters

NameTypeDescription
val int
mask int

Returns

bool

Remarks

This tests for a value, not a bit, by performing a bitwise AND between val and mask.

SetBit(int, int, bool)

Sets a bit in a bitmask.

public static int SetBit(int val, int bit, bool setting)

Parameters

NameTypeDescription
val int

The bitmask value to update.

bit int

The bit (0 - 31) to set

setting bool

Returns

int

SetFlags(int, int, bool)

Sets or clears a mask in a bitmask.

public static int SetFlags(int val, int mask, bool setting)

Parameters

NameTypeDescription
val int
mask int
setting bool

Returns

int

Remarks

This sets or clears a value, not a bit, by performing a bitwise OR between val and mask.