Fixed
Details
Assignee
Michael OffnerMichael OffnerReporter
Dan Switzer, IIDan Switzer, IIPriority
MajorFix 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
NoneAffects versions
Details
Details
Assignee
Michael Offner
Michael OffnerReporter
Dan Switzer, II
Dan Switzer, IIPriority
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
None
Affects versions
Created 10 September 2020 at 14:01
Updated 9 June 2023 at 15:32
Resolved 9 June 2023 at 15:32
Functions that have arguments specified as "numeric" do not treat the values as numeric.
For example, take the following function:
function isPositive(required numeric input, boolean debug=false) output=true { return (abs(arguments.input)== arguments.input); }
Now if you run the following, the results may not be as expected:
isPositive(0.08263888888888889); // returns true isPositive("0.08263888888888889"); // returns false
In ACF, both would return true, and that's what I'd expect to happen here.
The problem is that
arguments.input
ends up equaling0.08263888888888889
when the original input is a string, but when run throughabs()
it ends up being cast to a double and becomes0.082638888889
so when the values are compared, they are not equal.Here is a gist that shows off the issue:
https://www.trycf.com/gist/14bea07bc4311e74b5c06cc93b1280ad/lucee5?theme=monokai
It would seem like values being passed into a function with a data type of
numeric
should be cast to a double so that all math operations match. However, that could have some real ramifications.Alternatively, perhaps the comparison functions just need to be fixed so that when comparing a value that's a "string" to a native number type, that the string is cast to the same number type (i.e. cast to a double) so that the strings would be compared equally.