diff --git a/source2/Kernel/System/Cosmos.System.Plugs.System/Int32Impl.cs b/source2/Kernel/System/Cosmos.System.Plugs.System/Int32Impl.cs index 8bf5d6593..9d2466040 100644 --- a/source2/Kernel/System/Cosmos.System.Plugs.System/Int32Impl.cs +++ b/source2/Kernel/System/Cosmos.System.Plugs.System/Int32Impl.cs @@ -16,12 +16,15 @@ namespace Cosmos.System.Plugs.System { //at Cosmos.Build.MSBuild.IL2CPU.Execute() in M:\source\Cosmos\source2\Build\Cosmos.Build.MSBuild\IL2CPU.cs:line 250 C:\Program Files (x86)\MSBuild\Cosmos\Cosmos.targets 32 10 Guess (source2\Demos\Guess\Guess) // for instance ones still declare as static but add a aThis argument first of same type as target - public static int Parse(string s) { + public static int Parse(string s) + { int xResult = 0; - for (int i = s.Length - 1; i >= 0; i--) { + for (int i = s.Length - 1; i >= 0; i--) + { xResult = xResult * 10; - int j = Digits.IndexOf(s[i]); - if (j == -1) { + int j = s[i] - '0'; + if (j < 0 || j > 9) + { throw new Exception("Non numeric digit found in int.parse"); } xResult = xResult + j; diff --git a/source2/Kernel/System/Cosmos.System.Plugs.System/MathImpl.cs b/source2/Kernel/System/Cosmos.System.Plugs.System/MathImpl.cs index 43745d594..ae7702782 100644 --- a/source2/Kernel/System/Cosmos.System.Plugs.System/MathImpl.cs +++ b/source2/Kernel/System/Cosmos.System.Plugs.System/MathImpl.cs @@ -14,16 +14,11 @@ namespace Cosmos.System.Plugs.System public static double Abs(double value) { - double xResult; - if (value < 0) - { - xResult = value - (2 * value); - } - else - { - xResult = value; - } - return xResult; + if (value < 0) + return -value; + + else + return value; } //public static float Abs(float value) @@ -56,37 +51,34 @@ namespace Cosmos.System.Plugs.System public static int Abs(int value) { - int xResult; if (value < 0) - { - xResult = value - (2 * value); - } + return -value; + else - { - xResult = value; - } - return xResult; + return value; } public static double Pow(double x, double y) - { - double xResult = x; + { if (y == 0) { - xResult = 1; + return 1; } else if (y == 1) { - xResult = x; + return x; } else { + double xResult = x; + for (int i = 2; i <= y; i++) { xResult = xResult * x; } - } - return xResult; + + return xResult; + } } } } \ No newline at end of file