Duncan's blog

July 22, 2008

Coldfusion RandRange bug

Filed under: Coldfusion — duncan @ 6:21 pm
Tags: , , ,

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>

	<cfloop index="i" from="1" to="10">
		#RandRange(lower, upper)#<br>

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.



  1. Wow – that is a biggy.

    I’ve just tested this on cf7 and cf8 and I see the same behaviour on both.

    Seems like CF isn’t great with negatives…

    Is there an official location to post these bugs?

    Comment by Dan Lancelot — July 23, 2008 @ 9:21 pm | Reply

  2. For Coldfusion, just:

    I’ve reported this one as a CF 7 bug, feel free to re-post it as a CF 8 bug if you like.

    I think there was some talk of having a proper CF public bug tracker at some point, which would be ideal, as the current system is less than ideal. They already have this for Flex, Blaze DS and FlashPlayer ( http://bugs.adobe.com/ )

    Comment by duncancumming — July 24, 2008 @ 2:01 am | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: