Page 1 of 1

pow?

PostPosted: Thu Jun 09, 2011 5:42 pm
by Hblade
What does the pow command do, and how can I use it?

Re: pow?

PostPosted: Thu Jun 09, 2011 6:22 pm
by jimmynewguy
pow: Returns base raised to the exp power (base exp). A domain error may occur if base is zero and exp is less than or equal to zero. It will also happen if base is negative and exp is not an integer. A range error is possible.

double pow(double base, double exp);


Code: Select all
pow(2, 2);

would be 2^2 (two to the power of two) and return a four.

Re: pow?

PostPosted: Thu Jun 09, 2011 6:23 pm
by savvy
surely pow would be a number to the power of another number, if so this is useful.
so i = pow(5,2); would be 5 to the power of 2, so 5 x 5 which is 25. i think this is what it is.

EDIT: yes it is, its int 1 to the power of int 2
EDIT2: can use it to make calculators perhapse? can also be used if you want to get the square of a number... "pow(int,2);"

Re: pow?

PostPosted: Thu Jun 09, 2011 6:50 pm
by Hblade
Thanks :D This will be exellent as a score multiplyer for the game :) thanks guys

Re: pow?

PostPosted: Thu Jun 09, 2011 9:42 pm
by lcl
savvy wrote:can also be used if you want to get the square of a number... "pow(int,2);"

And sqrt(int); for square root. :)

Re: pow?

PostPosted: Thu Jun 09, 2011 11:58 pm
by Hblade
thanks :)