PHP在余数为零后查找Exponent

时间:2017-02-28 11:15:57

标签: php math

我已编写此代码,但我没有什么问题,或者可能是我遗漏了某些内容,

public function test()
{
    $number = "8192";
    for ($i=1; $i<=32; $i++)
        {
            if(($number % pow(2,$i)) == 0)
                {
                $final = 32-$i;
                echo $final;
                }
        }
    exit;
}

我需要使用哪个Exponent aka $ i然后需要减去32(或其他)的值来获得最终结果。

1 个答案:

答案 0 :(得分:0)

由于你想比较这些值只是改变if条件,模数运算符不会给你确切的结果,
这是完整的答案:

action = 'new-template.php'
相关问题