Open paulheckmann opened 1 month ago
I think this is a fair point. The documentation of the number()
function says it will convert the string into a number "if possible", and it definitely is possible to accept this number.
I checked, and the corresponding functions in Python, JavaScript, and Java all turn ".25"
into 0.25
. So clearly JSLT should do the same.
With a trailing decimal point, the three mentioned languages have 2 different outcomes.
But then, JS internally only uses floating point numeric type, which "covers" integers.
2 + 3. => 5
2 + 3. => 5.0
2 + 3. => 5.0 Only allowed for assignment to a double; illegal for an int or float
double a = 2 + 3
What do you want to support here ? Treat it as a dobule ?
Sorry for the late response. In this case, I would expect that it treats it as a double. What would be alternative? That it fails on converting the int to a double?
Currently the "number" function fails on this input: ".25" or "-.25".
Our data provider sends decimal numbers in that format, and so far JSLT is the only technology we use that cannot work with it.
We can work around it padding the string with a missing zero before feeding it into the "number" function.