Why is totals showing zero for me in this snippet?
Integer stats;
Decimal total;
Integer cntOrg=60;
stats=200;
total = stats/cntOrg;
system.debug('Values for '+org+' is ' + total);
Why is totals showing zero for me in this snippet?
Integer stats;
Decimal total;
Integer cntOrg=60;
stats=200;
total = stats/cntOrg;
system.debug('Values for '+org+' is ' + total);
Your stats
and cntOrg
should be in decimal then only output will be expected
Decimal stats;
Decimal total;
Decimal cntOrg=60;
stats=200;
total = stats/cntOrg;
system.debug('Values for '+org+' is ' + total);
If you divide integer datatype no. then result be in integer type.
So in your case 3
will be return not decimal numbers
If you divide Decimal datatype no.hen result be in Decimal type.
So in your case 3.33333333333333333333333333333333
will be return with decimal numbers
Decimal
no then it will return complete value .
Commented
Mar 20, 2016 at 14:39