POW(3) 1 POW(3)pow - Exponential expressionSYNOPSIS
number pow (number $base, number $exp)
DESCRIPTION
Returns $base raised to the power of $exp.
Note
In PHP 5.6 onwards, you may prefer to use the ** operator.
PARAMETERS
o $base
- The base to use
o $exp
- The exponent
RETURN VALUES
$base raised to the power of $exp. If both arguments are non-negative integers and the result can be represented as an integer, the result
will be returned with integer type, otherwise it will be returned as a float.
EXAMPLES
Example #1
Some examples of pow(3)
<?php
var_dump(pow(2, 8)); // int(256)
echo pow(-1, 20); // 1
echo pow(0, 0); // 1
echo pow(-1, 5.5); // PHP >4.0.6 NAN
echo pow(-1, 5.5); // PHP <=4.0.6 1.#IND
?>
NOTES
Note
This function will convert all input to a number, even non-scalar values, which could lead to weird results.
SEE ALSO exp(3), sqrt(3), bcpow(3), gmp_pow(3).
PHP Documentation Group POW(3)
Check Out this Related Man Page
POW(3) BSD Library Functions Manual POW(3)NAME
pow -- power function
SYNOPSIS
#include <math.h>
double
pow(double x, double y);
long double
powl(long double x, long double y);
float
powf(float x, float y);
DESCRIPTION
The pow() functions compute x raised to the power y.
SPECIAL VALUES
pow(+-0, y) returns +-infinity and raises the "divide-by-zero" floating-point exception for y an odd integer < 0.
pow(+-0, y) returns +infinity and raises the "divide-by-zero" floating-point exception for y < 0 and not an odd integer.
pow(+-0, y) returns +-0 for y an odd integer > 0.
pow(+-0, y) returns +0 for y > 0 and not an odd integer.
pow(-1, +-infinity) returns 1.
pow(1, y) returns 1 for any y, even a NaN.
pow(x, +-0) returns 1 for any x, even a NaN.
pow(x, y) returns a NaN and raises the "invalid" floating-point exception for finite x < 0 and finite non-integer y.
pow(x, -infinity) returns +infinity for |x| < 1.
pow(x, -infinity) returns +0 for |x| > 1.
pow(x, +infinity) returns +0 for |x| < 1.
pow(x, +infinity) returns +infinity for |x| > 1.
pow(-infinity, y) returns -0 for y an odd integer < 0.
pow(-infinity, y) returns +0 for y < 0 and not an odd integer.
pow(-infinity, y) returns -infinity for y an odd integer > 0.
pow(-infinity, y) returns +infinity for y > 0 and not an odd integer.
pow(+infinity, y) returns +0 for y < 0.
pow(+infinity, y) returns +infinity for y > 0.
A domain error occurs if x is finite and negative and y is finite and not an integer.
A domain error can occur if x is 0 and y less than or equal to 0.
Range errors may occur.
VECTOR OPERATIONS
If you need to apply the pow() functions to SIMD vectors or arrays, using the following functions provided by the Accelerate.framework may
give significantly better performance:
#include <Accelerate/Accelerate.h>
vFloat vpowf(vFloat x, vFloat y);
vFloat vpowf(vFloat x, vSInt32 y);
void vvpowf(float *z, const float *y, const float *x, const int *n);
void vvpow(double *z, const double *y, const double *x, const int *n);
void vvpowsf(float *z, const float *y, const float *x, const int *n);
void vvpows(double *z, const double *y, const double *x, const int *n);
SEE ALSO exp(3)math(3)STANDARDS
The pow() function conforms to ISO/IEC 9899:2011.
4th Berkeley Distribution December 11, 2006 4th Berkeley Distribution
Hi,
I would like to use a power function in Bash in an awk '{ } .
e.g pow(2,3)=8
Any suggestion? I try to find online resources but most of them stated by using BC.
Please advise. Thanks. (3 Replies)
Hi All,
a bit of a weird one here. I'm trying to pass a variable into an awk command, and I keep getting an error.
I have the line
nawk -F"," -v red=$random_variable '{print $red}' $w_dir/$file_name > $w_dir/${column_name}
that keeps failing with the error
nawk: can't open file {print... (17 Replies)
Hi, I need
to make some extraction . with the following input to get the right output.
input: /etc/exp/home/bin ====> output: exp
and
input: aex1234 ===> output: ex
Thanks for your help, (4 Replies)
Hi,
I want to calculate in terms of power.
for example = 16 pow 2 =256
i don't know what function to use in unix to calculate power.
Please help me.
ravi (3 Replies)
Bit of a weird one i suppose, i want to use an echo inside an echo... For example...
i have a script that i want to use to take users input and create another script. Inside this script it creates it also needs to use echos...
echo "echo "hello"" >$file
echo "echo "goodbye"" >$file
... (3 Replies)
Hi,
I am trying to use a regular exp to match any number between 0 and 7 except 2......
I am using:
echo $myvar | egrep "{1}{1}"
Which isnt working....
Please can someone help?
Thanks
yonderboy (10 Replies)
Hi,
I'm new to unix so hopefully you can help!
I'm using the below command to extract a tables contents and store it in a dmp file:
exp OWNER/OWNER@LINK FILE=exp.dat TABLES=TABLE_TEST
This works fine and dumps the table into the exp.dat file.
What i can't figure out, is how to... (3 Replies)
I am trying to write a script that raises a integer (m) by a exponent (n) using a while loop
ex. 5 raised to the power of 2 ..
I am a beginner and i dont know what is the opperand or command i have to use to make this happen..this is what i have so far...
echo "Enter a integer for the... (3 Replies)
Hi All,
Just faced an interesting thing in HP-UX. I was dividing 2955334616 / 2 by using echo `expr 2955334616 / 2` , and this ofcourse which expects 1477667308 to be returned. But I am getting -669816340 and I am :wall: how exactly this is possible. It is not one of the compliments (Ones or... (4 Replies)
Hi guys,
I was wondering if you could share some of your knowledge, in the event of a power outage.
Let presume you are on duty and you get a call at midnight because half of your cabinets have no power, air conditioning is down and you deal with a ton of 500 error messages on your boxes.
... (9 Replies)
Hello,
How can I change this code
a=$(egrep "exp" $logFiles -oh);
aCount=$(egrep "exp" $logFiles -oh| wc -l);
to something like this
a=$(egrep "exp" $logFiles -oh);
aCount = $a| wc -l
What I mean I do not want to execute the egrep twice because it takes a lot of time
Regards (6 Replies)
I've testing the following code:
echo test.txt | cut -d . -f1and get the output "text"
So why can't i assign the command to a variable?
VAR='"echo test.txt | cut -d . -f1"'
echo $VAR (5 Replies)
Greetings,
Let's say I want to find files matching "*.out" in the current dir. I can do a echo *.out. However, the result is separated by a white space. Is there a way to have the results separated by a new line instead?
I know this can be done by using find -maxdepth 1 -name '*.out'. The... (5 Replies)