0

How to calculate exponential in trigger?

2
1

your formula MarketValue$ =(Price__c* CMValue) / ((1 + Discount)^Contract) is not equal to expression: (50,000*.1)/((1 + .08)^1 + (50,000*.1)/((1 + .08)^2 = $8,916.32


If you want to implement expression in apex, you can do it by means of Math apex class:

Double price = 50000;
Double cmValue = 0.1;
Double coef = 1;
Double discount = 0.08;
Double contract = 2;
Double marketValue = (price * cmValue) / Math.pow(1 + discount, coef)  + ((price * cmValue) / Math.pow((1 + discount), contract));
System.debug('marketValue:' + marketValue);

and result is:

|DEBUG|marketValue:8916.323731138546

Not the answer you're looking for? Browse other questions tagged or ask your own question.