Skip to content

Instantly share code, notes, and snippets.

@jonoliver82
jonoliver82 / UShortExtensions.cs
Created March 13, 2019 14:51
Extract value from ushort at bit offset and width
public static class UShortExtensions
{
public static int Section(this ushort value, int offset, int width)
{
var mask = 0;
for (int i = 0; i < width; i++)
{
mask |= 1 << i;
}