You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2021/06/09 23:56:17 UTC

[commons-numbers] 01/05: Remove use of Math.fma

This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git

commit 2a8b86a20000f43fc454a1d1aa9ae4ee071513dd
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Jun 9 23:24:00 2021 +0100

    Remove use of Math.fma
---
 .../java/org/apache/commons/numbers/core/ExtendedPrecisionTest.java  | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/ExtendedPrecisionTest.java b/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/ExtendedPrecisionTest.java
index 85c5677..b153ebe 100644
--- a/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/ExtendedPrecisionTest.java
+++ b/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/ExtendedPrecisionTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.numbers.core;
 
+import java.math.BigDecimal;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
@@ -110,7 +111,9 @@ class ExtendedPrecisionTest {
     void testSquareLowUnscaled() {
         assertSquareLowUnscaled(0.0, 1.0);
         assertSquareLowUnscaled(0.0, -1.0);
-        assertSquareLowUnscaled(Math.fma(Math.PI, Math.PI, -Math.PI * Math.PI), Math.PI);
+        final double expected = new BigDecimal(Math.PI).pow(2)
+                .subtract(new BigDecimal(Math.PI * Math.PI)).doubleValue();
+        assertSquareLowUnscaled(expected, Math.PI);
 
         assertSquareLowUnscaled(Double.NaN, Double.POSITIVE_INFINITY);
         assertSquareLowUnscaled(Double.NaN, Double.NEGATIVE_INFINITY);