function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NekosanNekosan 

Rounding decimal

Which function I can use to get following result?
If price is 5.457333333
it should show 5.46
I used setscale function .It does not show correct rounding .
Anoop yadavAnoop yadav
Hi,
Try the below code on developer console.
Decimal d = 5.457333333;
d=d.setscale(2);
System.debug('TEST:'+d);

 
Jigar.LakhaniJigar.Lakhani
Hello,

For Visualforce Page
<apex:outputText value=”{0, number,###,###,##0.00}”>
    <apex:param value=”{!mynumber}” />
</apex:outputText>

Thanks and Cheers,
Jigar