Handling scientific notation in transforms


#1

Is there an expression engine function that handles scientific notation using E-notation?

example:

Canonical value (read in as a string): '-3.5061761E7'
Transform expression: ???
Desired data value (as a double): -35061761

current workaround is a transform expression like this:
~ expression "matchesRegex(<value>, 'E') ? number(split(<value>, 'E')[0]) * number(split(<value>, 'E')[1]) : <value>'"

but this seems like an operation that should be available in the platform out of the box


#2

posting a solution I just found –

casting the canonical string value as a number looks like it handles this case:

Expr.eval("number('-3.5061761E7')")
-35061761

How can I use ExpressionEngineFunction expressions in javascript code?
#3

FYI…This only seems to be working from 7.8. I get the ‘NotImplementedException’ in 7.7


#4

@venkata.paruchuri that error might be due to discrepancies between the methods available in Expr.eval vs. ExpressionEngineFunction library, and still could work in transformation logic. See this post for more context.

Can anyone on the Platform Team shed some light on this? @trothwein or @rohit.sureka?