forked from CosmosOS/Cosmos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInt64Impl.cs
52 lines (45 loc) · 1.15 KB
/
Int64Impl.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using Cosmos.Common;
using Cosmos.Debug.Kernel;
using IL2CPU.API;
using IL2CPU.API.Attribs;
namespace Cosmos.System_Plugs.System
{
[Plug(Target = typeof(Int64))]
public class Int64Impl
{
public static string ToString(ref long aThis)
{
return StringHelper.GetNumberString(aThis);
}
public static Int64 Parse(string s)
{
const string digits = "0123456789";
Int64 result = 0;
int z = 0;
bool neg = false;
if (s.Length >= 1)
{
if (s[0] == '+')
z = 1;
if (s[0] == '-')
{
z = 1;
neg = true;
}
}
for (int i = z; i < s.Length; i++)
{
Int64 ind = (Int64)digits.IndexOf(s[i]);
if (ind == -1)
{
throw new FormatException();
}
result = (Int64)((result * 10) + ind);
}
if (neg)
result *= -1;
return result;
}
}
}