Re: Calculations
| From: | tedd | Date: | Tue, 27 Jun 2006 17:45:48 +0000 |
| Subject: | Re: Calculations | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-238737@lists.php.net to get a copy of this message | ||
At 6:26 PM +0100 6/27/06, Alex Major wrote:
>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.
Try:
pow(2,3) //8
$cost = $farm_cost * (pow(2,$farm_level));
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com