Q:

Round off an apex variable upto two decimal places

I have apex variable in my visualforce page, which is calculated as below - 
<apex:variable var="cntFinal" value="{!IF(cntVar1==0,0,(cntVar2+cntVar3)*100/cntVar1)}"/>

Now, I want to set this cntFinal value up to two decimal places. For example,
if the value is 0.23769, I want to show 0.24.
This conversion have to be as Number, not as a string(using <apex:outputText> will convert it to text). As I will be using this to calculate other values.

A:

Keeping everything in visualforce here, there is a function to do precisely what you're looking for, ROUND.
It appears about half-way down the documentation page on visualforce functions

ROUND
  Returns the nearest number to a number you specify, constraining the new number by a specified number of digits.
ROUND(number, num_digits) and replace number with the field or expression you want rounded; replace num_digits with the number of decimal places you want to consider when rounding.

An example of usage:
<!-- 20/3 = 6.6666... rounding to 2 decimal places should result in 6.67 -->
<apex:variable var="myVar" value="{!ROUND(20/3, 2)}"/>

