You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2019/08/08 17:30:37 UTC
[commons-numbers] 14/18: NUMBERS-120: Add comment about previously
neglected corner case that was luckily already handled correctly
This is an automated email from the ASF dual-hosted git repository.
erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git
commit e89aaadec3b431c4e2f979c778d22c929f180803
Author: Schamschi <he...@gmx.at>
AuthorDate: Thu Jul 4 01:44:01 2019 +0200
NUMBERS-120: Add comment about previously neglected corner case that was luckily already handled correctly
---
.../java/org/apache/commons/numbers/fraction/BigFraction.java | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java
index a73a643..a9a50ee 100644
--- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java
+++ b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java
@@ -800,6 +800,16 @@ public class BigFraction extends Number implements Comparable<BigFraction>, Seri
!divisor.equals(BigInteger.ONE)
).longValue();
exponent = 0L;
+
+ /*
+ * Note: It is possible that an otherwise subnormal number will
+ * round up to the smallest normal number. However, this special
+ * case does not need to be treated separately, because the
+ * overflowing highest-order bit of the significand will then simply
+ * become the lowest-order bit of the exponent, increasing the
+ * exponent from 0 to 1 and thus establishing the implicity of the
+ * leading 1-bit.
+ */
}
return (sign << (significandLength + exponentLength)) | (exponent << significandLength) | significand;
}