2

((82125.49845) / (0 + 1)) * ((1 + ((2.84*1)/100)) / (1 + ((2.84*1)/100) + 0.005))^(14.083)
The above calculation gives me the correct value 76 703.2452

But when i does this stuff in salesforce using the Math.pow it doesn't gives me the exact result and help me to sort it out and below are the options which i used in salesforce apex class

1) System.debug('>>> pow=' + Math.pow((82125.49845 / (0 + 1)) * ((1 + ((2.84*1)/100)) / (1 + ((2.84*1)/100) + 0.005).doubleValue(),14.0832.doubleValue());

2) System.debug('>>> final=' +(82125.49845 / (0 + 1)) * ((1 + ((2.84*1)/100)) / (1 + ((2.84*1)/100) + 0.005)).pow(14.0832));

Prem Thilak
  • 31
  • 1
  • 4

1 Answers1

0

The problem is that the pow function only works with Doubles, which have less precision than the Decimal type for Real number calculations.

The Math class does support exponentiation with Decimals using natural exponents and natural logarithms though, so this should work for you:

Math.exp ( Math.log ((82125.49845) / (0 + 1)) + 14.083 * Math.log ((1 + ((2.84*1)/100)) / (1 + ((2.84*1)/100) + 0.005)) )
martin
  • 1,102
  • 2
  • 12
  • 20