PDA

View Full Version : easy mathematics



uygar
6th October 2010, 16:08
I know my problem is very easy, even for begginer but:


int aa=2;
int bb=3;
double abd=aa^bb;
but i have to do it like this but i couldn't

double aa=2.09;
double bb=3.04;
double abd=aa^bb;

error: invalid operands of types `double' and `double' to binary `operator^'
What is the solition?

tbscope
6th October 2010, 16:17
Like the error states, the ^ operator is a binary operator. It does not calculate the power.

You can use the math lib and the pow() function.

uygar
6th October 2010, 16:28
thank u, i found the way. it is like:

double aa=2.09;
double bb=3.04;
double abd=pow(aa,bb);

Urthas
6th October 2010, 20:07
Remember to print the values you get: qDebug() << (aa^bb). This would have shown you immediately that your understanding of the meaning of ^ was incorrect. :)