幂算子计算结果错误


Power operator calculating wrong results

实际上这两种方法是相同的,但是它们返回的结果不同。

echo round(200 / ((175/100)*(175/100)), 2);   Returns 65.31
echo round(200 / ((175/100)^2), 2);           Returns 66.67

操作顺序都是正确的,所以应该不会影响结果。创建了一个代码页

^表示按位异或,而不是幂。电源使用函数pow:

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