I have this function:
float ObliczRate(float fKwotaKredytu, float fOprocentowanie, int iIloscRat)
{
/*
Rata = K * y^n * (y-1) / (y^n-1);
y = 1 + (r / 12)
*/
float fRata, float fY;
fY = 1 + (fOprocentowanie / 12); // obliczanie stałej kredytu
fRata = fKwotaKredytu * fY^iIloscRat * (fY - 1) / (fY^iIloscRat - 1); // obliczanie raty stałej ze wzoru
return fRata;
}
And i have error: "error C2296: '^' : illegal, left operand has type 'float'" only on "(fY^iIloscRat - 1)". What's wrong with this?
It's because ^ is not an exponential operator, but the bitwise XOR operator. You want the std::pow function.
In C++ the operator ^ has a meaning of bitwise XOR operator not the power operation. You will have to use the pow function defined in the cmath header here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With