diff options
Diffstat (limited to 'ChocolArm64/ABitUtils.cs')
-rw-r--r-- | ChocolArm64/ABitUtils.cs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ChocolArm64/ABitUtils.cs b/ChocolArm64/ABitUtils.cs index 357dd45d..dd416235 100644 --- a/ChocolArm64/ABitUtils.cs +++ b/ChocolArm64/ABitUtils.cs @@ -27,6 +27,10 @@ namespace ChocolArm64 return -1; } + private static readonly sbyte[] HbsNibbleTbl = { -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3 }; + + public static int HighestBitSetNibble(int Value) => HbsNibbleTbl[Value & 0b1111]; + public static long Replicate(long Bits, int Size) { long Output = 0; @@ -54,4 +58,4 @@ namespace ChocolArm64 return Value != 0 && (Value & (Value - 1)) == 0; } } -}
\ No newline at end of file +} |