Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I always round down to the closest 10 whole number?

So, I have a query that returns a number of records. And on my results page I display a line that says: Results 1 to 10 out of 30+ results are shown below.

The 30+ number I get by doing this:

<!--- round to the nearest ten --->
<cfset totalfoundRounded = Round(myquery.recordcount/ 10) * 10>

This works great if my recordcount is for example 34 or less. Or 24 or less, basically as soon as it gets over 5, my code rounds up. So even if there are only 18 records, it will say 20+ records found.

I have been scratching my head on how to get this logic to work, so that it always rounds down to the nearest 10, even if it's 18, or 19.

I tried using int() but that didn't work, it only works on decimal places.

So, is there a function in coldfusion, or some technique I'm missing to get this to work? I have been unable to find anything searching, and math is not my strong point :(

Thank you very much for any suggestions!!

like image 777
Jennifer Avatar asked Dec 07 '22 08:12

Jennifer


1 Answers

Try this?

<cfset totalfoundRounded = Int(myquery.recordcount/ 10) * 10>
like image 71
Daniel Williams Avatar answered Dec 08 '22 21:12

Daniel Williams