lucee5: writeOutput(round(0.35/100*45000)) = 157 ...
# lucee
r
lucee5: writeOutput(round(0.35/100*45000)) = 157 lucee6: writeOutput(round(0.35/100*45000)) = 158 I need to reproduce this bug on Lucee 6 to provide backward compatibility in my application. Can I do it by type casting or something else?
d
That's a weird behavior, but Lucee 5 is consistent with ACF: https://www.trycf.com/gist/47ac33b261daa79669b97556faabe1c3/lucee6?theme=monokai It's weird because
0.35/100*45000
=
157.5
which should round up to
158
(so Lucee 6 is the only one that gets it correct), but ACF produces
157
like Lucee 6 does.
e
weird 2, round function does right thing, must be internal calculation flow somewhere
m
I wonder if precisionEvaluate() would help?
d
All of the versions will correctly round a hardcoded
157.5
up to
158
, which tells me there must be some floating point issue happening with the way the value is stored.
m
with precisionEvaluate() on 2021 and 2023, result is 158
r
I found solution how to reproduce it on lucee6: x = javaCast("float", 0.35) / javaCast("float", 100) * javaCast("float", 45000); writeOutput(round(x));
c
This was recently discussed on the Lucee forum: https://dev.lucee.org/t/validate-integer/14563/4