Re: Calculations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Try:

pow($base, $exp);

http://us2.php.net/manual/en/function.pow.php

Not sure why PHP doesn't use the ^.. havn't looked to see if it's already used for something else.

-TG

= = = Original message = = =

Hi there list. 
Thanks for your help with my other questions.

I was carrying on working through, and stumbled across a problem when trying
to times something by the 'power' of something. By this I mean..in maths you
can write 3 * (2 ^ 3), the answer to which would be 24. (as 2 ^ 3 = 8).

The reason that I need this, is because I'm trying to double a variable x
amount of times (x is set by another variable).

For example my code is:

$cost = $farm_cost * (2 ^ $farm_level);

Any ideas how I would go about changing my calculation, as php dosn't seem
to recognise ^ meaning 'to the power of'.

Regards, 
Alex.


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux