Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,18 @@ protected Dfp(final DfpField field, final String s) {

// Don't want to run pass the end of the array
if (q == mant.length * rsize + offset + 1) {
// the digits left before the decimal point are dropped,
// but they still count towards the magnitude
if (!decimalFound) {
decimalPos = significantDigits;
while (p < fpdecimal.length() && fpdecimal.charAt(p) != '.') {
if (fpdecimal.charAt(p) >= '0' && fpdecimal.charAt(p) <= '9') {
decimalPos++;
}
p++;
}
decimalFound = true;
}
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,23 @@ public void testStringConstructorExponentRange() {
DfpField.FLAG_UNDERFLOW, "String #1");
}

@Test
public void testStringConstructorDigitsBeyondPrecision() {
// integer digits that do not fit in the mantissa still set the magnitude
test(field.newDfp("123456789012345678901234567890"),
field.newDfp("1.2345678901234567890123e29"),
DfpField.FLAG_INEXACT, "String #2");
test(field.newDfp("-100000000000000000000000000000"),
field.newDfp("-1e29"),
0, "String #3");
test(field.newDfp("1234567890123456789012345678.5"),
field.newDfp("1.2345678901234567890123e27"),
DfpField.FLAG_INEXACT, "String #4");
test(field.newDfp("123456789012345678901234567890e-10"),
field.newDfp("1.2345678901234567890123e19"),
DfpField.FLAG_INEXACT, "String #5");
}

@Test
public void testAdd() {
test(field.newDfp("1").add(field.newDfp("1")), // Basic tests 1+1 = 2
Expand Down
Loading