BigDecimal Invalid operation error with pow() / exponent

Description

points = [ [ 0 , 0 ] , [ (10 ^ -14.1305100087), 1 ] , [ (10 ^ -13.8630800087), 2 ] , [ (10 ^ -13.5956500087), 3 ] , [ (10 ^ -13.3282200087), 4 ] , [ (10 ^ -13.0607900087), 5 ] , [ (10 ^ -12.7933600087), 6 ] , [ (10 ^ -12.5259300087), 7 ] , [ (10 ^ -12.2585000087), 8 ] , [ (10 ^ -11.9910700087), 9 ] , [ (10 ^ -11.7236400087), 10 ] ];

throws

lucee.runtime.exp.NativeException: Invalid operation [java] [script] at java.base/java.math.BigDecimal.pow(BigDecimal.java:2438) [java] [script] at lucee.runtime.op.OpUtil.exponentRef(OpUtil.java:1005) [java] [script] at tickets.exp.index_cfm$cf.call(/test/tickets/exp/index.cfm:4)

works with 5.x and 6.0.0.313
https://trycf.com/gist/1e2557c0f6d0f9bd35d442c9c74a886e/lucee6-beta?theme=monokai

https://github.com/lucee/Lucee/blob/6.0/core/src/main/java/lucee/runtime/op/OpUtil.java#L1005

public static Number exponentRef(PageContext pc, Object left, Object right) throws PageException { if (AppListenerUtil.getPreciseMath(pc, null)) { return Caster.toBigDecimal(left).pow(Caster.toIntValue(right)); } return Caster.toDouble(StrictMath.pow(Caster.toDoubleValue(left), Caster.toDoubleValue(right))); }

Environment

None

Activity

Pothys - MitrahSoft 
29 May 2023 at 06:25

I checked this ticket with lucee fixed version 6.0.0.406-SNAPSHOT. BigDecimal doesn't cause an “Invalid operation“ error. It works fine and it didn't even cause "Division by zero" error.

Michael Offner 
26 May 2023 at 20:02

cn you please add a test case for this

Zac Spitzer 
23 May 2023 at 07:06

Pothys - MitrahSoft 
22 May 2023 at 11:35
(edited)

checked this ticket with above code on latest lucee version 6.0.0.388-SNAPSHOT. Now preciseMath doesn't throw an “Invalid operation” error and it works fine

Fixed

Details

Assignee

Reporter

Priority

Fix versions

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Sprint

Affects versions

Created 13 April 2023 at 15:18
Updated 30 May 2023 at 13:09
Resolved 30 May 2023 at 13:09