How to convert Double.POSITIVE_INFINITY to BigDecimal?

java

Solution

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.

Problem

I tried `BigDecimal.valueOf(Double.POSITIVE_INFINITY)`, but kept getting `NumberFormatException` Thanks

Original source