ColdFusion ‘Round()’ docs inaccurate?

Today I needed a function which would return me a whole number, rounding either up or down depending on whether the value passed to the function was less than or greater than .5

Looking at round() ColdFusion 8 docs they say:

Rounds a number to the closest integer that is larger than the input parameter.

Hmm, that doesn’t sound right.

In actual fact the round() function does exactly what it should, rounds numbers down OR up.

Round(7.49) = 7
Round(7.5) = 8
Round(7.65) = 8
Round(-7.49) = -7
Round(-7.5) = -7
Round(-7.65) = -8

Also funny to note that although the docs site is much better for ColdFusion 8, many of the examples using ColdFusion variables are not parsed. So you get examples like #Round(7.49)#.

Hopefully Adobe will rectify this soon.

Post a Comment or Leave a Trackback

One Comment

  1. Frank Wheatley
    October 12, 2007 at 1:17 pm | Permalink

    Is the an easy way to round with precision?
    1.244 = 1.24 and
    1.245 = 1.25

    Currently, I multiply by 10, round, then divide by 10.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*