I tried BigDecimal.valueOf(Double.POSITIVE_INFINITY)
, but kept getting NumberFormatException
Thanks
You cannot represent infinity in BigDecimal
.
This behavior corresponds to the documented way the valueOf
method is supposed to work:
Parameters: val - double to convert to a BigDecimal.
Returns: a BigDecimal whose value is equal to or approximately equal to the value of val.
Throws: NumberFormatException - if val is infinite or NaN.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With