The calculation formula for several powers in PHP is "$x=pow(base, exponent);", and the value of variable x is the result of the power calculation. The pow() function can calculate and return the result of the specified power of the specified number. The first parameter specifies the base of the exponential expression, and the second parameter specifies the power of the exponential expression. If it cannot be calculated, the returned result is NAN.
The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer.
The calculation formula is:
$x=pow(底数,指数);
Function: The function of the pow() function is to calculate a number to the nth power Return
Syntax:
pow(X,Y);
Parameters:
X represents the number to be processed
Y represents the n value in the specified nth power
Description: Returns the Y power of X. If the parameters are correct, the function will return a numerical value. If it cannot be calculated, it will return NAN.
Examples are as follows:
<?php echo(pow(2,4) . "<br>"); echo(pow(-2,4) . "<br>"); echo(pow(-2,-4) . "<br>"); echo(pow(-2,-3.2)); ?>
Output results:
## Recommended learning: "PHP Video Tutorial 》
The above is the detailed content of What is the formula for calculating several powers in php. For more information, please follow other related articles on the PHP Chinese website!