Create StoneRed.LogicSimulator.Api project

This commit is contained in:
Stone_Red
2023-10-13 12:24:15 +02:00
parent 4a43a1d2ef
commit 2cd4168cfd
27 changed files with 77 additions and 60 deletions
@@ -0,0 +1,34 @@
namespace StoneRed.LogicSimulator.Api.Utilities;
#pragma warning disable S112 // General exceptions should never be thrown
internal static class BitHelper
{
public static void SetBit(this ref int input, int value, int index)
{
if (index >= 32)
{
throw new IndexOutOfRangeException();
}
if (value == 1)
{
input |= 1 << index;
}
else
{
input &= ~(1 << index);
}
}
public static int GetBit(this int input, int index)
{
if (index >= 32)
{
throw new IndexOutOfRangeException();
}
return (input >> index) & 1;
}
}
#pragma warning restore S112 // General exceptions should never be thrown