Math
Execute and test PHP functions with an mathmatic background. These functions use and except only float and integer values.
abs
Returns the absolute value of $number.
acos
Returns the arc cosine of $arg in radians. acos() is the complementary function of cos(), which means that a==cos(acos(a)) for every value of a that is within acos()' range.
acosh
Returns the inverse hyperbolic cosine of $arg, i.e. the value whose hyperbolic cosine is $arg.
asin
Returns the arc sine of $arg in radians. asin() is the complementary function of sin(), which means that a==sin(asin(a)) for every value of a that is within asin()'s range.
asinh
Returns the inverse hyperbolic sine of $arg, i.e. the value whose hyperbolic sine is $arg.
atan2
This function calculates the arc tangent of the two variables $x and $y. It is similar to calculating the arc tangent of $y / $x, except that the signs of both arguments are used to determine the quadrant of the result.
The function returns the result in radians, which is between -PI and PI (inclusive).
atan
Returns the arc tangent of $arg in radians. atan() is the complementary function of tan(), which means that a==tan(atan(a)) for every value of a that is within atan()'s range.
atanh
Returns the inverse hyperbolic tangent of $arg, i.e. the value whose hyperbolic tangent is $arg.
base_convert
Returns a string containing $number represented in base $tobase. The base in which $number is given is specified in $frombase. Both $frombase and $tobase have to be between 2 and 36, inclusive. Digits in numbers with a base higher than 10 will be represented with the letters a-z, with a meaning 10, b meaning 11 and z meaning 35.
bindec
Returns the decimal equivalent of the binary number represented by the $binaryString argument.
calculate
This function calculates a mathmatic formula. It is somewhat like a calculator, but without an usable frontend. Often you have the problem, that you just want write down the complete formular, but on GUI-based calculators you can't, here you can! Allowed are the usual operators (+, -, *, /, %) and the following functions:
- exp($arg) (exp(1) = 2,718...)
- log($arg, $basis) (log(2, 8) = 1/3)
- pow($basis, $exponent) (pow(4, 2) = 16)
- sqrt($arg) (sqrt(16) = 4)
Attention: The comma (,) is reserved to devide the parameters of function. The comma in this way is represented by the dot (.).
ceil
Returns the next highest integer value by rounding up $value if necessary.
cos
cos() returns the cosine of the $arg parameter. The arg parameter is in radians.
cosh
Returns the hyperbolic cosine of $arg, defined as (exp(arg) + exp(-arg))/2.
decbin
Returns a string containing a binary representation of the given $number argument. The largest number that can be converted is 4294967295 in decimal resulting to a string of 32 1's.
dechex
Returns a string containing a hexadecimal representation of the given $number argument. The largest number that can be converted is 4294967295 in decimal resulting to "ffffffff".
decoct
Returns a string containing an octal representation of the given $number argument. The largest number that can be converted is 4294967295 in decimal resulting to "37777777777".
deg2rad
This function converts $number from degrees to the radian equivalent.
exp
Returns e raised to the power of $arg.
expm1
expm1() returns the equivalent to 'exp($arg) - 1' computed in a way that is accurate even if the value of $arg is near zero, a case where 'exp($arg) - 1' would be inaccurate due to subtraction of two numbers that are nearly equal.
floor
Returns the next lowest integer value by rounding down $value if necessary.
fmod
Returns the floating point remainder of dividing the dividend ($x) by the divisor ($y). The reminder (r) is defined as: $x = i * $y + r, for some integer i. If $y is non-zero, r has the same sign as $x and a magnitude less than the magnitude of $y.
hexdec
Returns the decimal equivalent of the hexadecimal number represented by the $hexString argument. hexdec() converts a hexadecimal string to a decimal number.
hypot
hypot() returns the length of the hypotenuse of a right-angle triangle with sides of length $x and $y, or the distance of the point ($x, $y) from the origin. This is equivalent to sqrt($x*$x + $y*$y).
is_finite
Checks whether $val is a legal finite on this platform.
is_infinite
Returns TRUE if $val is infinite (positive or negative), like the result of log(0) or any value too big to fit into a float on this platform.
is_nan
Checks whether $nval is 'not a number', like the result of acos(1.01).
log10
Returns the base-10 logarithm of $arg.
log1p
log1p() returns log(1 + $number) computed in a way that is accurate even when the value of $number is close to zero. log() might only return log(1) in this case due to lack of precision.
log
If the optional base parameter is specified, log() returns logbase $arg, otherwise log() returns the natural logarithm of $arg.
max
If the first and only parameter is an array, max() returns the highest value in that array. If at least two parameters are provided, max() returns the biggest of these values.
min
If the first and only parameter is an array, min() returns the lowest value in that array. If at least two parameters are provided, min() returns the smallest of these values.
mt_rand
Many random number generators of older libcs have dubious or unknown characteristics and are slow. By default, PHP uses the libc random number generator with the rand() function. The mt_rand() function is a drop-in replacement for this. It uses a random number generator with known characteristics using the « Mersenne Twister », which will produce random numbers four times faster than what the average libc rand() provides.
If called without the optional $min, $max arguments mt_rand() returns a pseudo-random value between 0 and mt_getrandmax(). If you want a random number between 10 and 100 (inclusive), for example, use mt_rand(10, 100).
octdec
Returns the decimal equivalent of the octal number represented by the $octalString argument.
pow
Returns $base raised to the power of $exp.
rad2deg
This function converts $number from radian to degrees.
rand
If called without the optional $min, $max arguments rand() returns a pseudo-random integer between 0 and getrandmax(). If you want a random number between 5 and 15 (inclusive), for example, use rand(5, 15).
round
Returns the rounded value of $val to specified $precision (number of digits after the decimal point). $precision can also be negative or zero (default).
sin
sin() returns the sine of the $arg parameter. The $arg parameter is in radians.
sinh
Returns the hyperbolic sine of $arg, defined as (exp($arg) - exp(-$arg))/2.
sqrt
Returns the square root of $arg.
tan
tan() returns the tangent of the $arg parameter. The $arg parameter is in radians.
tanh
Returns the hyperbolic tangent of $arg, defined as sinh($arg)/cosh($arg).