rj-action-library/Runtime/Bits/BitMath.cs

31 lines
580 B
C#
Raw Normal View History

2025-01-08 18:46:17 +00:00
using Godot;
namespace Rokojori
{
public class BitMath
{
public static int GetInt32BitMask( int bit )
{
return ( 1 << bit );
}
public static int SetBit( int value, int bitPosition )
{
return value | GetInt32BitMask( bitPosition );
}
public static int UnsetBit( int value, int bitPosition )
{
return value & ~GetInt32BitMask( bitPosition );
}
public static bool IsBitSet( int value, int bitPosition )
{
var mask = GetInt32BitMask( bitPosition );
return ( value & mask ) == mask;
}
}
}