Jump to content

sqrt(x) VS pow(x,1/2)


JRaz

Recommended Posts

1 ) sqrt()
[code]$t1 = microtime(true);
for($i=1;$i<=1000;$i++){
    $x = sqrt($i);
}
$t2 = microtime(true);
for($i=1;$i<=1000;$i++){
    $y = pow($i, 1/2);
}
$t3 = microtime(true);
echo 'sqrt : ', $t2-$t1, '<br>';
echo 'pow  : ', $t3-$t2, '<br>';[/code]

2 ) AFAIK it is the only way.
Link to comment
https://forums.phpfreaks.com/topic/11768-sqrtx-vs-powx12/#findComment-44553
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.