Skip to content

Commit

Permalink
GP-4759 corrected BigFloat formatting of -0.0 (Closes #6677)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghidra1 committed Jul 9, 2024
1 parent 76923e1 commit 282c6b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,9 @@ private String formatSpecialCase() {
if (isInfinite()) {
return sign < 0 ? NEGATIVE_INFINITY : POSITIVE_INFINITY;
}
if (isZero()) {
return sign < 0 ? "-0.0" : "0.0";
}
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,11 @@ private void doTestValueOfBigInteger(BigDecimal bdVal) {
@Test
public void testValueOfBigInteger() {
FloatFormat ff = FloatFormatFactory.getFloatFormat(8);
assertEquals("0.0", ff.toDecimalString(ff.getBigFloat(BigInteger.ZERO)));

assertFalse(ff.getBigZero(true).equals(ff.getBigZero(false)));

assertEquals("-0.0", ff.toDecimalString(ff.getBigZero(true)));
assertEquals("0.0", ff.toDecimalString(ff.getBigZero(false)));
assertEquals("1.0", ff.toDecimalString(ff.getBigFloat(BigInteger.ONE)));
assertEquals("2.0", ff.toDecimalString(ff.getBigFloat(BigInteger.TWO)));
assertEquals("-1.0", ff.toDecimalString(ff.getBigFloat(BigInteger.ONE.negate())));
Expand Down

0 comments on commit 282c6b6

Please sign in to comment.