简体   繁体   中英

Math power doesn't work correctly in formula in php

I am trying to add this formula into my PHP script:

50x^(y−10)

In this example: x = 1.1 and y = 99 which makes the formula:

50*1.1^(99-10)

This should return ~241501.0278 as result. But when I apply this in PHP, I only get 110 as output.

$vocMultiplier = 1.1;
$startSkill = 99;
$amountOfHits = 50 * $vocMultiplier ^($startSkill - 10);
echo $amountOfHits;

What am I doing wrong here?

Reference: here

You are mis-interpreting the ^ symbol for the pow function.

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

^ is the Bitwise Exclusive Or operator.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM