mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-24 12:35:31 +00:00
Merge branch 'master' into feature/AnonymousTypeTests
This commit is contained in:
commit
535e04b269
3 changed files with 32 additions and 4 deletions
|
|
@ -18,6 +18,8 @@ namespace Cosmos.Compiler.Tests.Bcl.System
|
||||||
expectedResult = "18446744073709551615";
|
expectedResult = "18446744073709551615";
|
||||||
|
|
||||||
Assert.IsTrue((result == expectedResult), "UInt64.ToString doesn't work");
|
Assert.IsTrue((result == expectedResult), "UInt64.ToString doesn't work");
|
||||||
|
Assert.IsTrue(value.ToString("X") == "FFFFFFFFFFFFFFFF", "UInt64.ToString(X) doesn't work");
|
||||||
|
Assert.IsTrue(((ulong)0x121411443).ToString("X") == "121411443", "UInt64.ToString(X) doesn't work");
|
||||||
|
|
||||||
// Now let's try to concat to a String using '+' operator
|
// Now let's try to concat to a String using '+' operator
|
||||||
result = "The Maximum value of an UInt64 is " + value;
|
result = "The Maximum value of an UInt64 is " + value;
|
||||||
|
|
|
||||||
|
|
@ -112,13 +112,22 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convert 64-bit unsigned int to 16 characters long hexadecimal string, padded with '0's.
|
/// Convert 64-bit unsigned int to 16 characters long hexadecimal string, optionally padded with '0's.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="aValue">A 64-bit unsigned int to be converted to hexadecimal string.</param>
|
/// <param name="aValue">A 64-bit unsigned int to be converted to hexadecimal string.</param>
|
||||||
/// <returns>16 characters long string value, padded with '0's.</returns>
|
/// <param name="withPadding">Determines if a left padding should be applied</param>
|
||||||
public static string ToHex(this ulong aValue)
|
/// <returns>16 characters long string value, optionally padded with '0's.</returns>
|
||||||
|
public static string ToHex(this ulong aValue, bool withPadding = true)
|
||||||
{
|
{
|
||||||
return ConvertToHex(aValue).PadLeft(16, '0');
|
var hex = ConvertToHex(aValue);
|
||||||
|
if (withPadding)
|
||||||
|
{
|
||||||
|
return hex.PadLeft(16, '0');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return hex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using Cosmos.Common;
|
using Cosmos.Common;
|
||||||
|
using Cosmos.Common.Extensions;
|
||||||
using IL2CPU.API;
|
using IL2CPU.API;
|
||||||
using IL2CPU.API.Attribs;
|
using IL2CPU.API.Attribs;
|
||||||
|
|
||||||
|
|
@ -12,5 +13,21 @@ namespace Cosmos.System_Plugs.System
|
||||||
{
|
{
|
||||||
return StringHelper.GetNumberString(aThis);
|
return StringHelper.GetNumberString(aThis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string ToString(ref ulong aThis, string formating)
|
||||||
|
{
|
||||||
|
if(formating == "X")
|
||||||
|
{
|
||||||
|
return ToHexString.ToHex(aThis, false);
|
||||||
|
}
|
||||||
|
else if(formating == "G")
|
||||||
|
{
|
||||||
|
return ToString(ref aThis);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue