Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
BitArithmetic.cs
Go to the documentation of this file.
1
namespace
System.Reflection.Internal
;
2
3
internal
static
class
BitArithmetic
4
{
5
internal
static
int
CountBits
(
int
v)
6
{
7
return
CountBits
((uint)v);
8
}
9
10
internal
static
int
CountBits
(uint v)
11
{
12
v -= (v >> 1) & 0x55555555;
13
v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
14
return
(
int
)(((v + (v >> 4)) & 0xF0F0F0F) * 16843009) >> 24;
15
}
16
17
internal
static
int
CountBits
(ulong v)
18
{
19
v -= (v >> 1) & 0x5555555555555555L;
20
v = (v & 0x3333333333333333
L
) + ((v >> 2) & 0x3333333333333333
L
);
21
return
(
int
)(((v + (v >> 4)) & 0xF0F0F0F0F0F0F0F
L
) * 72340172838076673
L
>> 56);
22
}
23
24
internal
static
uint
Align
(uint position, uint alignment)
25
{
26
uint num = position & ~(alignment - 1);
27
if
(num == position)
28
{
29
return
num;
30
}
31
return
num + alignment;
32
}
33
34
internal
static
int
Align
(
int
position,
int
alignment)
35
{
36
int
num = position & ~(alignment - 1);
37
if
(num == position)
38
{
39
return
num;
40
}
41
return
num + alignment;
42
}
43
}
System.Reflection.Internal.BitArithmetic.Align
static int Align(int position, int alignment)
Definition
BitArithmetic.cs:34
System.Reflection.Internal.BitArithmetic.CountBits
static int CountBits(int v)
Definition
BitArithmetic.cs:5
System.Reflection.Internal.BitArithmetic.CountBits
static int CountBits(uint v)
Definition
BitArithmetic.cs:10
System.Reflection.Internal.BitArithmetic.CountBits
static int CountBits(ulong v)
Definition
BitArithmetic.cs:17
System.Reflection.Internal.BitArithmetic.Align
static uint Align(uint position, uint alignment)
Definition
BitArithmetic.cs:24
System.Reflection.Internal.BitArithmetic
Definition
BitArithmetic.cs:4
System.Reflection.Internal
Definition
AbstractMemoryBlock.cs:4
System.ConsoleKey.L
@ L
source
System.Reflection.Metadata
System.Reflection.Internal
BitArithmetic.cs
Generated by
1.10.0