commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1060918 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java
Date Wed, 19 Jan 2011 19:26:45 GMT
Author: sebb
Date: Wed Jan 19 19:26:45 2011
New Revision: 1060918

URL: http://svn.apache.org/viewvc?rev=1060918&view=rev
Log:
MATH-478 FastMath is not an exact replacement for StrictMath
Add signum(float)

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

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java?rev=1060918&r1=1060917&r2=1060918&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java Wed
Jan 19 19:26:45 2011
@@ -579,7 +579,16 @@ public class FastMath {
      * @return -1, 0, +1 or NaN depending on sign of a
      */
     public static double signum(final double a) {
-       return (a < 0.0) ? -1.0 : ((a > 0.0) ? 1.0 : a);
+        return (a < 0.0) ? -1.0 : ((a > 0.0) ? 1.0 : a);
+    }
+
+    /** Compute the signum of a number.
+     * The signum is -1 for negative numbers, +1 for positive numbers and 0 otherwise
+     * @param a number on which evaluation is done
+     * @return -1, 0, +1 or NaN depending on sign of a
+     */
+    public static float signum(final float a) {
+        return (a < 0.0f) ? -1.0f : ((a > 0.0f) ? 1.0f : a);
     }
 
     /** Compute next number towards positive infinity.



Mime
View raw message