Exponential Operator
-
Here is the code that I am working with; void balance(float pmt) { float bal_k; int k=1; float pay; float i=9/12; const int n=36; pay=pmt; bal_k=pay*(1-((1+i)^(k-n))/i) } When I compile, the compiler says that because the left hand operator of the "bal_k" expression is of type float that it is illegal. I tried forcing the expression "i" to type int but it becomes zero and then there is a divide by zero error. How can I get around this?
-
Here is the code that I am working with; void balance(float pmt) { float bal_k; int k=1; float pay; float i=9/12; const int n=36; pay=pmt; bal_k=pay*(1-((1+i)^(k-n))/i) } When I compile, the compiler says that because the left hand operator of the "bal_k" expression is of type float that it is illegal. I tried forcing the expression "i" to type int but it becomes zero and then there is a divide by zero error. How can I get around this?
actually, your problem is that the "^" is the XOR operator in C++. You will need to use the pow() function in in order to do exponents.
Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life!