mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Added helper to count bits from uint.
This commit is contained in:
@@ -32,10 +32,13 @@
|
|||||||
using System;
|
using System;
|
||||||
namespace DiscImageChef.Helpers
|
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\ExtentsUShort.cs" />
|
||||||
<Compile Include="Extents\ExtentsByte.cs" />
|
<Compile Include="Extents\ExtentsByte.cs" />
|
||||||
<Compile Include="Extents\ExtentsSByte.cs" />
|
<Compile Include="Extents\ExtentsSByte.cs" />
|
||||||
|
<Compile Include="CountBits.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user