Details
Description
We have an expression which can create values which are to big for BigDecimal.
If the expression is printed out dircetly, it creates the value "Infinity" (Double.POSITIVE_INFINITY) which is fine.
If expression is used as an assignment to a variable, a confusing NumberFormatException without a message text is created.
Example:
BigDecimal x = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
println x ** 5 // ok, prints out "Infinity"
BigDecimal y = x ** 5 // not ok, creates a NumberFormatException without a message text
println y
java.lang.NumberFormatException
at java.math.BigDecimal.<init>(BigDecimal.java:455)
at java.math.BigDecimal.<init>(BigDecimal.java:724)
at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:284)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:602)
...
I suggest to check in DefaultTypeTransformation.castToType, line 284 for NaN and Infinity and create a NumberFormatException with a proper text like the Constructor BigDecimal (double val) does.