Quantcast
Channel: Jamie Krug's ColdFusion Blog - Railo
Viewing all articles
Browse latest Browse all 12

ColdFusion round() function bug when operation performed on argument

$
0
0
UPDATE (July 15, 2009): This "bug" still exists in Adobe ColdFusion 9 beta 1. It also seems to behave the same in OpenBD 1.1. This bug does not seem to exist in Railo (I can't reproduce any similar problems in Railo 3.0 or Railo 3.1). For example, round(4.0005*1000) outputs 4000 from both AdobeCF and OpenBD while Railo outputs the expected 4001. There may very well be other scenarios where a floating point representation causes similar unexpected results in Railo as well, but I have not been able to find it yet (nor have I performed an absolutely thorough test, maybe soon if time permits). Have you ever used a CFML trick like this to round a number to the nearest hundredth? #round(someNumber*100)/100# I have, and I never had a problem, until... valueA = 4000.5; valueB = 4.0005*1000; roundedA = round(valueA); roundedB = round(valueB); You'd be perfectly sane to expect the first two variables to output as 4000.5 and the second two (rounded) to output 4001. Unfortunately, roundedB is output as 4000, not4001! This definitely appears to be a bug, but I do have a rather simple workaround... [More]

Viewing all articles
Browse latest Browse all 12

Trending Articles