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.
Best Answer
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
An example of usage: