mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 12:30:32 +00:00
52 lines
1.4 KiB
C#
52 lines
1.4 KiB
C#
using System;
|
|
|
|
using Cosmos.IL2CPU.Plugs;
|
|
|
|
namespace Cosmos.System.Plugs.System
|
|
{
|
|
[Plug(Target = typeof(UInt64))]
|
|
public class UInt64Impl
|
|
{
|
|
public static string ToString(ref ulong aThis)
|
|
{
|
|
return UInt64Impl2.GetNumberString(aThis, false);
|
|
}
|
|
}
|
|
|
|
// See note in UInt32Impl
|
|
public class UInt64Impl2
|
|
{
|
|
public static string GetNumberString(ulong aValue, bool aIsNegative)
|
|
{
|
|
const string xDigits = "0123456789";
|
|
char[] xResultChars = new char[21];
|
|
int xCurrentPos = 20;
|
|
if (aValue > 0)
|
|
{
|
|
while (aValue > 0)
|
|
{
|
|
byte xPos = (byte)(aValue % 10);
|
|
aValue /= 10;
|
|
xResultChars[xCurrentPos] = xDigits[xPos];
|
|
xCurrentPos -= 1;
|
|
}
|
|
}
|
|
else {
|
|
xResultChars[xCurrentPos] = '0';
|
|
xCurrentPos -= 1;
|
|
}
|
|
if (aIsNegative)
|
|
{
|
|
xResultChars[xCurrentPos] = '-';
|
|
xCurrentPos -= 1;
|
|
}
|
|
return new String(xResultChars, xCurrentPos + 1, 20 - xCurrentPos);
|
|
}
|
|
|
|
// The value of the lower 32 bits XORed with the uppper 32 bits.
|
|
public static int GetHashCode(ref UInt64 aThis)
|
|
{
|
|
return (unchecked((int)((long)aThis)) ^ (int)(aThis >> 32));
|
|
}
|
|
}
|
|
}
|