Decimal a = 60000.000; Decimal b = 2000.0000; system.debug(a/b);
Expected Output: 30
Is there anything did I miss? Why this weird behavior?
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
As mentioned in the question comments by kurunve 30E+1 is same as 30 but still if you want to see 30 in the debug logs you can either round the output to nearest integer by using
Math.round(decimalValueHere) or if decimal points are required then you may use set scale as below:
Decimal a = 60000.000; Decimal b = 2000.0000; system.debug((a/b).setScale(4)); //output: 30.0000 as we have set scale to 4