Dan Lancelot posted about a bug he was experiencing in CF 8, with Query of Queries.
I tried a little bit of code to replicate the bug in CF 7. In doing so, I came across the following bug in the RandRange function.
<cfset lower = -10> <cfset upper = -5> <cfoutput> <cfloop index="i" from="1" to="10"> #RandRange(lower, upper)#<br> </cfloop> </cfoutput>
What seemed to happen is, with negative numbers CF would add 1 to the value. So in the example above, I would only ever see values between -9 and -4. It would never display -10, and it would go beyond -5 up to -4. If you set both lower and upper = -5, it will display -4 ten times. If you set upper to -1, it will display zero some of the time.
If I’m right and not being stupid (always a possibility) this seems like a pretty major bug to me. According to the documentation, RandRange works between -2,147,483,648 and 2,147,483,647.




