
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
PHP – How to raise an arbitrary precision number to another using bcpow() function?
In PHP, bcpow() function is used to raise an arbitrary precision base number to another exponent number. It takes two arbitrary precision numbers as strings and gives the base number raised to the power exponent after scaling the result to the listed precision.
Syntax
String bcpow($base, $exponent, $scale)
Parameters
The bcpow() function in PHP takes three different parameters: $base, $exponent and $scale.
$base - It represents the base in which power will be raised and it is the string type parameter.
$exponent - It represents the exponent and it is the string type parameter.
$scale - It indicates the number of digits that appear after the decimal in the result of exponent of a base exponent. Its default value is 0 and it is an integer type parameter.
Return Value
The bcpow() function returns the value of (Base)Exponent .
Example1 - bcpow() PHP function without using scale parameter
<?php // input base and exponent numbers $base = "5"; $exponent = "7"; // calculates the value //number without scale value $result = bcpow($base, $exponent); //used equal parameters echo "The output is: ", $result; ?>
Output
The output is: 78125
Example 2 - bcpow() PHP function using scale parameter
Let us now take the same input values with a scale of 3 and check the output.
<?php // input base and exponent numbers $base = "2"; $exponent = "3"; //used scale value two $scaleval = 3; // calculates the value //number without scale value $result = bcpow($base, $exponent, $scaleval); //used equal parameters echo "Output with scale value: ", $result; ?>
Output
Output with scale value: 8.000
- Related Articles
- PHP – How to subtract one arbitrary precision number from another using bcsub() function?
- PHP – How to get the modulus of an arbitrary precision number using bcmod() function?
- PHP – How to get the square root of an arbitrary precision number using bcsqrt() function?
- PHP – How to add two arbitrary precision numbers using bcadd() function?
- PHP – How to multiply two arbitrary precision numbers using bcmul() function?
- PHP – How to divide two arbitrary precision numbers using bcdiv() function?
- PHP – How to compare two arbitrary precision numbers using bccomp() function?
- In MySQL, how to raise a number to the power of another number?
- How to Play an arbitrary tone in Android using Kotlin?
- How to copy the palette from one image to another using imagepalettecopy() function in PHP?
- How to destroy an image in PHP using imagedestroy() function?
- How to draw an ellipse using imageellipse() function in PHP?
- How to crop an image to the given rectangle using imagecrop() function using PHP?
- How to crop an image automatically using imagecropauto() function in PHP?
- How to launch any arbitrary iPhone application from within another app?
