Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can work hard coded but not cmd line

Status
Not open for further replies.

desanti

Programmer
Jul 9, 2004
51
0
0
US
i am passing variables pv,rte,yrs to pgm.
BEGIN {printf ("%4.3f",(pv * rte)^yrs)} #this works passing
pv = 887.10,rte=1.04,yrs=3.
aNS = 1000.this gives future value.

this does not; BEGIN {printf ("%4.3f",(pv / rte)^yrs)}
this should give the original pv(887.10)
using pv = 1000,rte=1.04,yrs=3 giving the approximate answer.

i get zero divide.i can't see the forest for the trees.
 


This
Code:
BEGIN {printf ("%4.3f",(pv [red][b]*[/b][/red] rte)^yrs)}

is different than this

Code:
BEGIN {printf ("%4.3f",(pv [red][b]/[/b][/red] rte)^yrs)}

 
???

I get different results...

$ awk 'BEGIN{printf ("%4.3f\n", (887.10*1.04)^3)}'
785267738.728

$ awk 'BEGIN{printf ("%4.3f\n", (1000/1.04)^3)}'
888996358.671

p5


 
I think you should use the following formulas:
pv * (rte^yrs)
pv / (rte^yrs)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
To PHV neither of those work.
TO P5WIZARD the first should work.
the second is fine but the decimal is wrong(888.96)


#BEGIN {printf ("%4.3f\n",(pv * rte)^yrs)} #this works passing variables pv(887.10),rte,yrs. gives fv.

BEGIN {printf ("%4.3\nf",(pv / rte)^yrs)} #this does NOT work using pv =1000(should get 887.10)!!!

#the variables are as in the cmnd line

#BEGIN {printf ("%4.3f\n",1000 / (1 + .04)^3)} #this works for future and for present(/ or *).
#hard coded.

in the above if you put 887.10 for pv and multiply * uou get the correct answer.if you put in a 1000 for pv and /,you get 889.96.it should come to 887.10 but one problem at a time!!
 
i miskeyed "%4.3f\n" as "%4.3\nf".it is correct in the program.how do i respond to individual answers to my query??
thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top