DEADSOFTWARE

Допилен модуль CPMath
[dsw-obn.git] / rtl / java / CPMath.java
index 28f8a6d29c19ea94aad72e8838e4985947b9f35f..33472c7868d41d45588f033f8022b7b365437ead 100644 (file)
@@ -97,7 +97,29 @@ public class CPMath
 
        public static double IntPower(double x, int n)
        {
-               return Math.pow(x, n);
+               double y = 1.0;
+
+               if(n < 0)
+               {
+                       x = 1.0 / x;
+                       n = -n;
+               }
+
+               while(n > 0)
+               {
+                       if(n % 2 == 1)
+                       {
+                               y = y * x;
+                               n -= 1;
+                       }
+                       else
+                       {
+                               x = x * x;
+                               n = n / 2;
+                       }
+               }
+
+               return y;
        }
 
        public static double Ln(double x)
@@ -112,9 +134,8 @@ public class CPMath
 
        public static double Mantissa(double x)
        {
-               // Not implemented
-               SYSTEM.TRAP(-3);
-               return 0;
+               int exponent = Math.getExponent(x);
+               return x / Math.pow(2, exponent);
        }
 
        public static double Pi()