+ 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
RovRov
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);