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

30 lines
575 B
C#

using Godot;
using System;
using System.Text;
namespace Rokojori
{
public class Bytes
{
public static byte SetBit( byte value, int position )
{
return (byte) ( ( 1 << position ) | value );
}
public static byte UnsetBit( byte value, int position )
{
var mask = 1 << position;
var invertedMask = ~mask;
return (byte)( value & invertedMask );
}
public static bool IsBitSet( byte value, int position )
{
var mask = 1 << position;
return ( mask & value ) == mask ;
}
}
}