gpt4 book ai didi

Php,用插入符号(^)计算指数失败

转载 作者:可可西里 更新时间:2023-11-01 13:04:14 24 4
gpt4 key购买 nike

Wolfram Alpha 表示将为以下公式给出正确的结果:

((0.0004954*($current^2))-((0.935*$current)+378.486))-
((0.0004954*($desired^2))-((0.935*$desired)+378.486));

但是当我在 PHP 中运行它时,它没有给出正确的答案,为什么不呢?

$current = mysql_escape_string($_POST['current']);
$desired = mysql_escape_string($_POST['desired']);
$username = mysql_escape_string($_POST['username']);
$password = mysql_escape_string($_POST['password']);
$email = mysql_escape_string($_POST['email']);
$ip = $_SERVER["REMOTE_ADDR"];
$time = time();
$elo = $desired - $current;
if($current < 1200) {
$price = ($elo/100)*30;
} elseif($current < 1400) {
$price = ($elo/100)*35;
} elseif($current < 1901) {
$price = ((0.0004954*($current^2))-((0.935*$current)+378.486))-((0.0004954*($desired^2))-((0.935*$desired)+378.486));
}

最佳答案

^ 运算符是一个 bitwise运营商。

您需要使用 pow .

如果你只想对一个值进行平方,那么你可以将它乘以它本身,$current * $current

关于Php,用插入符号(^)计算指数失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14371386/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com