Scott Steinbeck
01/25/2023, 10:46 PMpublic void function testPrecisionEvaluateString(){
var p1 = 23.74;
var p2 = 37.05;
var pe = precisionEvaluate('p1 + p2'); //works correctly
assertEquals( pe, 60.79 );
}
public void function testPrecisionEvaluate(){
var p1 = 23.74;
var p2 = 37.05;
var pe = precisionEvaluate(p1 + p2); //returns trailing decimal place .7900000001
assertEquals( pe, 60.79 );
}
What is the actual difference that could cause this?Adam Cameron
p1 + p2 before doing the precision piece, whereas with the former the whole thing is being handled within the inner workings of precisionEvaluate.
Just a guess though. I have NFI how precisionEvaluate works.
(and trycf.com is not helping here... /me shakes fist at Abram, whilst laughing)Adam Cameron
Scott Steinbeck
01/25/2023, 10:53 PMbdw429s
01/25/2023, 11:02 PMbdw429s
01/25/2023, 11:03 PMScott Steinbeck
01/25/2023, 11:07 PMprecisionEvaluate('a + b')Adam Cameron
precisionEvaluate did similar sort of magic to parameterExists or isNull and somehow didn't evaluate the expression before it was passed into it. If that makes sense.Adam Cameron
Adam Cameron
=== is broke on Lucee. Sigh.Adam Cameron
p1 = 23.74;
p2 = 37.05;
f = p1 + p2
expected = 60.79
pe = precisionEvaluate(p1 + p2); //returns trailing decimal place .7900000001
writeDump([
expected = expected, // 60.79
"expected.toString()" = expected.toString(), // 60.79
"pe" = pe, // 60.79
"pe.toString()" = pe.toString(), // 60.79
"f.toString()" = f.toString() // 60.78999999999999
])
https://i.paste.pics/7f5278a4947b7104e84c92e2868f7554.png▾