changes for reading input files
[IRC.git] / Robust / src / ClassLibrary / Math.java
index 63147285925c4db698f30ae38a11c5589438236e..9a7f14183f783cb6af7cc485141c49c0d342aed0 100644 (file)
@@ -1,71 +1,67 @@
 public class Math {
+  static final double PI=3.14159265358979323846;
 
-  public static double setPI() {
+  // an alias for setPI()
+  public static double PI() {
     double PI = 3.14159265358979323846;
     return PI;
   }
 
-  public static double fabs(double x) {
-    if (x < 0) {
-      return -x;
-    } else {
-      return x;
-    }
+  public static int abs(int x) {
+    return (x<0)?-x:x;
+  }
+
+  public static long abs(long x) {
+    return (x<0)?-x:x;
   }
 
   public static double abs(double x) {
-    if (x < 0) {
-      return -x;
-    } else {
-      return x;
-    }
+    return (x<0)?-x:x;
   }
 
-  public static float abs(float a) {
-    if (a<0)
-      return -a;
-    else return a;
+  public static float abs(float x) {
+    return (x<0)?-x:x;
   }
 
   public static double max(double a, double b) {
-    if(a == b)
-      return a;
-    if(a > b) {
-      return a;
-    } else {
-      return b;
-    }
+    return (a>b)?a:b;
   }
 
-  public static int imax(int a, int b) {
-    if(a == b)
-      return a;
-    if(a > b) {
-      return a;
-    } else {
-      return b;
-    }
+  public static float max(float a, float b) {
+    return (a>b)?a:b;
   }
 
-  public static int imin(int a, int b) {
-    if(a == b)
-      return a;
-    if(a > b) {
-      return b;
-    } else {
-      return a;
-    }
+  public static int max(int a, int b) {
+    return (a>b)?a:b;
+  }
+
+  public static long max(long a, long b) {
+    return (a>b)?a:b;
+  }
+
+  public static double min(double a, double b) {
+    return (a<b)?a:b;
+  }
+
+  public static float min(float a, float b) {
+    return (a<b)?a:b;
+  }
+  public static int min(int a, int b) {
+    return (a<b)?a:b;
+  }
+  public static long min(long a, long b) {
+    return (a<b)?a:b;
   }
 
   /** sqrt(a^2 + b^2) without under/overflow. **/
   public static double hypot(double a, double b) {
     double r;
-    if (fabs(a) > fabs(b)) {
+    if (abs(a) > abs(b)) {
       r = b/a;
-      r = fabs(a)*sqrt(1+r*r);
+      r = abs(a)*sqrt(1+r*r);
     } else if (b != 0) {
       r = a/b;
-      r = fabs(b)*sqrt(1+r*r);
+      r = abs(b)*sqrt(1+r*r);
     } else {
       r = 0.0;
     }
@@ -77,9 +73,9 @@ public class Math {
     double d = y - x;
     if( d == 0.5 ) {
       if( ((int)y)%2 == 0 ) {
-       return y;
+        return y;
       } else {
-       return y - 1.0;
+        return y - 1.0;
       }
     } else if( d < 0.5 ) {
       return y;
@@ -93,6 +89,7 @@ public class Math {
   public static native double acos(double a);
   public static native double tan(double a);
   public static native double atan(double a);
+  public static native double atan2(double a, double b);
   public static native double exp(double a);
   public static native double sqrt(double a);
   public static native double log(double a);
@@ -107,4 +104,6 @@ public class Math {
   public static native float sqrtf(float a);
   public static native float logf(float a);
   public static native float powf(float a, float b);
+  public static native float ceilf(float a);
+  public static native float IEEEremainder(float f1, float f2);
 }