Author: erans
Date: Fri Jan 17 10:53:00 2014
New Revision: 1559067
URL: http://svn.apache.org/r1559067
Log:
MATH-1089
Slightly simpler implementation.
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java?rev=1559067&r1=1559066&r2=1559067&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java
Fri Jan 17 10:53:00 2014
@@ -60,6 +60,8 @@ public class Precision {
private static final long SGN_MASK = 0x8000000000000000L;
/** Offset to order signed double numbers lexicographically. */
private static final int SGN_MASK_FLOAT = 0x80000000;
+ /** Positive zero. */
+ private static final double POSITIVE_ZERO = 0d;
static {
/*
@@ -396,7 +398,7 @@ public class Precision {
.setScale(scale, roundingMethod))
.doubleValue();
// MATH-1089: negative values rounded to zero should result in
negative zero
- return rounded == 0.0 ? rounded * FastMath.copySign(1d, x) :
rounded;
+ return rounded == POSITIVE_ZERO ? POSITIVE_ZERO * x : rounded;
} catch (NumberFormatException ex) {
if (Double.isInfinite(x)) {
return x;