/** * Get a value of this {@link LongsBsonDecimal128} in an equivalent BigDecimal * * @return BigDecimal equivalent to this Decimal128 */ @Override public BigDecimal getValue() { if (isNaN()) { throw new ArithmeticException("Can not get value of NaN"); } if (isInfinite()) { throw new ArithmeticException("Can not get value of Infinite"); } BigDecimal value = getBigDecimal(); // If the BigDecimal is 0, but the Decimal128 is negative, that means we have -0. if (isNegative() && value.signum() == 0) { throw new ArithmeticException("Negative zero can not be converted to a BigDecimal"); } return value; }