1
0
mirror of synced 2024-12-04 20:08:00 +01:00
Switch-Toolbox/Switch_Toolbox_Library/IO/Bits/Bit.cs

23 lines
594 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Toolbox.Library.IO
{
public class Bit
{
//From https://github.com/shibbo/flyte/blob/337383c01c50dff155e4b4e170d248118db0c0aa/flyte/utils/Bit.cs
public static uint ExtractBits(uint val, int numBits, int startBit)
{
uint mask = 0;
for (int i = startBit; i < startBit + numBits; i++)
mask |= (0x80000000 >> i);
return (val & mask) >> (32 - (startBit + numBits));
}
}
}