1

I have this forumula in a Excel sheet :

=IF(B$3=0,B$14*B$2*B$6,(1-((1+B$3))^B$6)/LN(1/(1+B$3))*B12*B$2)

where cells:

B2 = 40000

B3 = 1.0%

B6 = 30

B12 = 10.0%

B14 = 20.0%

The excel produces the following result: 139,834

I started looking at the 'else' part seeing as B3 not equal to 1, however I having issues with my calculations in JavaScript. Below is what I got (code is inside a function):

    var B2 = 40000; 
    var B3 =  1/100; 
    var B6 = 30; 
    var B12 = 10/100;
    var B14 = 20/100;

    var calc = Math.pow ((1-(1+B3)),B6) / Math.log ( (1 / (1+B3)) * B12 * B2);

    return ( calc );

What I'm getting back is 1.2071318349401829e-61

Anyone know where I'm going wrong or how I would go about getting the correct result in JavaScript?

Any help appreciated.

2
  • in your js, B14 is worth 10% (VS 20% in Excel), is it a typo ? Commented Jul 22, 2011 at 14:22
  • Yes sorry that is a type it should be 20% - var B14 = 20/100; Commented Jul 22, 2011 at 14:28

1 Answer 1

4

In excel you have

1-((1+B$3))^B$6

which is the same as

1-(1+B$3)^B$6

in javascript you have

Math.pow ((1-(1+B3)),B6)

which is different

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.