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
balaji_SFDCbalaji_SFDC 

How to get round off value by using two decimal values

I used Below codes  i didn't get any result

Decimal toRound = 3.14159265359;   
Decimal rounded = Math.round(toRound, 2);
system.debug(rounded);

Decimal toround = 3.14159265;
Decimal rounded = toround.setScale(2);
system.debug(rounded);

Best Answer chosen by balaji_SFDC
SabrentSabrent
Your 2nd solution gives the desired result i.e 3.14
I tested it in Dev console. 

Decimal toround = 3.14159265;
Decimal rounded = toround.setScale(2);
system.debug(rounded);