commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aherb...@apache.org
Subject [commons-numbers] 06/07: Fraction: Fix divide to return this if it is zero.
Date Thu, 09 Apr 2020 11:34:48 GMT
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 6cabdbc54d0af1976339e000217950a88b583e79
Author: aherbert <aherbert@apache.org>
AuthorDate: Thu Apr 9 12:32:19 2020 +0100

    Fraction: Fix divide to return this if it is zero.
---
 .../src/main/java/org/apache/commons/numbers/fraction/Fraction.java    | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
index fa7b377..c5a883d 100644
--- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
+++ b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
@@ -633,6 +633,9 @@ public final class Fraction
         if (value.isZero()) {
             throw new FractionException(FractionException.ERROR_DIVIDE_BY_ZERO);
         }
+        if (isZero()) {
+            return this;
+        }
         return multiply(value.reciprocal());
     }
 


Mime
View raw message