Home  >  Article  >  Backend Development  >  What is the formula for calculating several powers in php

What is the formula for calculating several powers in php

WBOY
WBOYOriginal
2022-03-25 17:22:023349browse

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.

What is the formula for calculating several powers in php

The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer.

What is the calculation formula for several powers in php

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:

What is the formula for calculating several powers in php

## 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn