26 (edited by AD1408 2016-09-26 00:24:00)

Re: One Form MVD app

Hi Lee,


Converting % value was easy,


However, I couldn't create a formula to calculate "Compound Growth Rate" correctly.


InitalValue1 1000
OutputFuturevalue 2593
Periods1 10


Calc. should return
Compound Growth Rate: 10

Adam
God... please help me become the person my dog thinks I am.

Re: One Form MVD app

i have no idea what the steps are to do what ou are trying to do.  actually i have no idea what you are trying to do.  i have no education in the area you are working in.

Re: One Form MVD app

Here is the math formula I was trying to apply to MVD script code but couldn't get it working:


OutputGrowthRate = (FutureValue / InitialValue1)^(1/ Periods1)-1

Adam
God... please help me become the person my dog thinks I am.

Re: One Form MVD app

Hello AD1408,


I think you are just using the power function wrong and mixing calculation priorities, nothing serious :-)


here is a sample project to help you, with commented code. But pay attention to :
- avoiding divisions by 0
- calculation priorities
- floating point overflow (when numbers are just too great...)


Hope this will help, I did this on a hurry just before work this morning.


Have a good day



Mathias

Post's attachments

Attachment icon AD1408.zip 333.92 kb, 400 downloads since 2016-09-26 

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

30 (edited by AD1408 2016-09-26 23:16:35)

Re: One Form MVD app

Hi Mathias,


Great stuff as usual...


Thanks a lot for the sample project and excellent commenting on code.



-----------------------------------------


I have checked the sample calc, but I think it returns incorrect results.


You can test calc results here.

http://www.investopedia.com/calculator/cagr.aspx

Adam
God... please help me become the person my dog thinks I am.

Re: One Form MVD app

try changing line 23: futurval := Power((futurval DIV initialval),period) -1;
to read: futurval := Power((futurval DIV initialval),(1 DIV period)) -1;  he was using period and your formula calls for the reciprocal of period

Re: One Form MVD app

Thanks Lee.....


but formula

futurval := Power((futurval DIV initialval),(1 DIV period)) -1; 

returns 0

Adam
God... please help me become the person my dog thinks I am.

Re: One Form MVD app

the problem turns out to be that 1 divided by anything gives the result of 0.  i am not sure what is causing it. i havent been able to figure out why. it may be a bug, i dont know. maybe Dmitry can figure out that part for you. everything else in the zip file looks to be ok.