You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have some integers (below the safe limit of 2^53 - 1) that are being rounded to precision 15 once we use $string() on them.
This seems due to the following line of code, specifically the positive unary case, ? Number(val.toPrecision(15))
The precision is limited to avoid the inaccuracy of decimal arithmetic showing up in the string (see #194 (comment)). This even shows up occasionally for toPrecision(16), e.g with the expression Account.Order.$string($sum(Product.(Price* Quantity))) on the exerciser sample data.
To work around this, since you know you are dealing with integers, use the $formatInteger() function instead of $string().
E.g. $formatInteger(9007199254740991, '0') => "9007199254740991"
We have some integers (below the safe limit of
2^53 - 1
) that are being rounded to precision15
once we use$string()
on them.This seems due to the following line of code, specifically the positive unary case,
? Number(val.toPrecision(15))
jsonata/src/functions.js
Line 134 in d7790e8
I can submit a PR but my question is whether there is a good reason for the limit. I would not want to regress something else.
Repro:
The text was updated successfully, but these errors were encountered: