Skip to content

Commit e2cd33e

Browse files
committed
Use valueOf(double) with round(MathContext)
instead of new BigDecimal(Double.toString(double), MathContext)
1 parent 74746de commit e2cd33e

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/main/java/org/firebirdsql/decimal/Decimal.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,7 @@ final T valueOf(double value, OverflowHandling overflowHandling) {
373373
return getSpecialConstant(Signum.NEGATIVE, DecimalType.INFINITY);
374374
}
375375

376-
// TODO Use new BigDecimal(double, MathContext) instead, has slightly different precision?
377-
return valueOf(new BigDecimal(Double.toString(value), getMathContext()), overflowHandling);
376+
return valueOf(BigDecimal.valueOf(value).round(getMathContext()), overflowHandling);
378377
}
379378

380379
/**

0 commit comments

Comments
 (0)