mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Added helper to count bits from uint.
This commit is contained in:
@@ -32,10 +32,13 @@
|
||||
using System;
|
||||
namespace DiscImageChef.Helpers
|
||||
{
|
||||
public class CountBits
|
||||
public static class CountBits
|
||||
{
|
||||
public CountBits()
|
||||
public static int Count(uint number)
|
||||
{
|
||||
number = number - ((number >> 1) & 0x55555555);
|
||||
number = (number & 0x33333333) + ((number >> 2) & 0x33333333);
|
||||
return (int)((((number + (number >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
<Compile Include="Extents\ExtentsUShort.cs" />
|
||||
<Compile Include="Extents\ExtentsByte.cs" />
|
||||
<Compile Include="Extents\ExtentsSByte.cs" />
|
||||
<Compile Include="CountBits.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user