Round function

Hi,

In Adobe Coldfusion, the round function is to rounds a number to the closest integer. In the Lucee documentation for the Round function, the description is :

Rounds a number to the closest integer.

But there is an optional argument, precision, for the number of decimals.

Round(3.1415926535, 2) <!--- Will return 3.14 on Lucee --->

Can I trust this function to round a number to two decimal places, like 3.1415926535 to 3.14? If this is the case, the documentation should be updated in this direction, because it leaves me in doubt and I wonder if I will not have a bad surprise during an update of Lucee. Especially since Adobe Coldfusion continues to round to the nearest integer.

Thank you!

Yes, you can. The description is just a little poor, and probably copied at some point from Adobe. The docs are stored in Github if you want to send a pull. Iā€™d change it to say something like it rounds to the closest integer when no precision is provided, and when you provide a precision, it will round to that many decimal places.

2 Likes

Thank you! It reassures me!

@bdw429s and @TonyMonast no need to PR it. I did it right away:

Hope this description is better.

3 Likes