Author: luc
Date: Tue Mar 26 19:48:08 2013
New Revision: 1461283

URL: http://svn.apache.org/r1461283
Log:
Replaced mask constant by explicit local constants.

Modified:
    
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/FastMath.java

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/FastMath.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/FastMath.java?rev=1461283&r1=1461282&r2=1461283&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/FastMath.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/FastMath.java
 Tue Mar 26 19:48:08 2013
@@ -307,6 +307,12 @@ public class FastMath {
     /** Mask used to clear low order 30 bits */
     private static final long MASK_30BITS = -1L - (HEX_40000000 -1); // 
0xFFFFFFFFC0000000L;
 
+    /** Mask used to clear the non-sign part of an int. */
+    private static final int MASK_NON_SIGN_INT = 0x7fffffff;
+
+    /** Mask used to clear the non-sign part of a long. */
+    private static final long MASK_NON_SIGN_LONG = 0x7fffffffffffffffl;
+
     /** 2^52 - double numbers this large must be integral (no fraction) or NaN 
or Infinite */
     private static final double TWO_POWER_52 = 4503599627370496.0;
     /** 2^53 - double numbers this large must be even. */
@@ -3011,7 +3017,7 @@ public class FastMath {
      * @return abs(x)
      */
     public static float abs(final float x) {
-        return Float.intBitsToFloat(Integer.MAX_VALUE & 
Float.floatToRawIntBits(x));
+        return Float.intBitsToFloat(MASK_NON_SIGN_INT & 
Float.floatToRawIntBits(x));
     }
 
     /**
@@ -3020,7 +3026,7 @@ public class FastMath {
      * @return abs(x)
      */
     public static double abs(double x) {
-        return Double.longBitsToDouble(Long.MAX_VALUE & 
Double.doubleToRawLongBits(x));
+        return Double.longBitsToDouble(MASK_NON_SIGN_LONG & 
Double.doubleToRawLongBits(x));
     }
 
     /**


Reply via email to