Esempio n. 1
0
 /**
  * Replacement function for double comparison
  *
  * @param d1 a double.
  * @param d2 a double.
  * @return a int.
  */
 public static int doubleSub(double d1, double d2) {
   if (d1 == d2) {
     if (Properties.DYNAMIC_SEEDING) {
       ConstantPoolManager.getInstance().addDynamicConstant(d1);
     }
     ;
     return 0;
   } else {
     double diff = d1 - d2;
     double diff2 = diff / (1.0 + Math.abs(diff));
     if (Double.isNaN(d1) || Double.isNaN(d2) || Double.isInfinite(d1) || Double.isInfinite(d2)) {
       return Double.compare(d1, d2);
     }
     //			int d3 = (int) Math.round(Integer.MAX_VALUE * diff2);
     int d3 =
         (int)
             (diff2 < 0
                 ? Math.floor(Integer.MAX_VALUE * diff2)
                 : Math.ceil(Integer.MAX_VALUE * diff2));
     if (Properties.DYNAMIC_SEEDING) {
       ConstantPoolManager.getInstance().addDynamicConstant(d1);
       ConstantPoolManager.getInstance().addDynamicConstant(d2);
     }
     ;
     return d3;
   }
 }
Esempio n. 2
0
 /**
  * Replacement function for long comparison
  *
  * @param l1 a long.
  * @param l2 a long.
  * @return a int.
  */
 public static int longSub(long l1, long l2) {
   if (l1 == l2) {
     if (Properties.DYNAMIC_SEEDING) {
       ConstantPoolManager.getInstance().addDynamicConstant(l1);
     }
     ;
     return 0;
   } else {
     double diff = l1 - l2;
     double diff2 = Math.signum(diff) * Math.abs(diff) / (1.0 + Math.abs(diff));
     int d3 = (int) Math.ceil(Integer.MAX_VALUE * diff2);
     if (Properties.DYNAMIC_SEEDING) {
       ConstantPoolManager.getInstance().addDynamicConstant(l1);
       ConstantPoolManager.getInstance().addDynamicConstant(l2);
     }
     ;
     return d3;
   }
 }
Esempio n. 3
0
 /**
  * Replacement function for float comparison
  *
  * @param f1 a float.
  * @param f2 a float.
  * @return a int.
  */
 public static int floatSub(float f1, float f2) {
   if (f1 == f2) {
     if (Properties.DYNAMIC_SEEDING) {
       ConstantPoolManager.getInstance().addDynamicConstant(f1);
     }
     ;
     return 0;
   } else {
     double diff = f1 - f2;
     double diff2 = Math.signum(diff) * Math.abs(diff) / (1.0F + Math.abs(diff));
     if (Float.isNaN(f1) || Float.isNaN(f2) || Float.isInfinite(f1) || Float.isInfinite(f2)) {
       return Float.compare(f1, f2);
     }
     int d3 = (int) Math.ceil(Integer.MAX_VALUE * diff2);
     if (Properties.DYNAMIC_SEEDING) {
       ConstantPoolManager.getInstance().addDynamicConstant(f1);
       ConstantPoolManager.getInstance().addDynamicConstant(f2);
     }
     ;
     return d3;
   }
 }