I have written this code and run anonymously, and got some strange results which seem to indicate a bug in Math.Round(decimal)
- look like an overflow:
Decimal d = 1000000000.0;
Decimal dd = 10000000000.0;
Decimal ddd = 100000000000000.0;
System.debug('d='+d);
System.debug('dd='+dd);
System.debug('ddd='+ddd);
System.debug('round d='+Math.round(d));
System.debug('round dd='+Math.round(dd));
System.debug('round ddd='+Math.round(ddd));
Results are:
d=1000000000.0
dd=10000000000.0
ddd=100000000000000.0
round d=1000000000
round dd=1410065408
round ddd=276447232
As you see, it's wrong from dd onwards
.
Is this definitely a bug, or am I misunderstanding something? If it is a bug, has anyone else found this? Is there a workaround?
System.debug('dd=')
but in your results you haveddd=
FYI