Core PHP

Basic Math Functions

Math Functions
abs()
various abs(various $xNumber)
This function returns the absolute value of $xNumber. The function can take either an integer or a double, and the return type matches the argument type. The domain of the function is (- ∞, ∞) and the range is [0, ∞).
Argument Description
various $xNumber This is the independent variable value.
ceil()
double ceil(double $dNumber)
This function returns the next largest integer value above $dNumber, but it is returned as a double. The domain of the function is (-∞, ∞) and the range is ℤ.
Argument Description
double $dNumber This is the independent variable value.
deg2rad()
double deg2rad(double $dRadians)
This function returns the degree conversion of $dRadians in radians.
Argument Description
double $dRadians This is the value, in radians, that is to be converted to degrees.
floor()
double floor(double $dNumber)
This function returns the next integer below $dNumber. The domain of the function is (-∞, ∞) and the range is ℤ.
Argument Description
double $dNumber This is the independent variable value.
fmod()
double fmod(double $dDividend, double $dDivisor)
This function returns the remainder of the division of $dDividend by $dDivisor: $dDividend = quotient*$dDivisor + remainder.
Argument Description
double $dDividend This is the number that is being divided.
double $dDivisor This is the number that is the divisor.
hypot()
double hypot(double $dA, double $dB)
This function returns the length of the hypotenuse for the triangle with side lengths $dA and $dB: sqrt($dA*$dA + $dB*$dB).
Argument Description
double $dA This is one side length of the triangle.
double $dB This is the other side length of the triangle.
intdiv()
integer intdiv(integer $iDividend, integer $iDivisor)
This function returns the quotient of the integer division of $iDividend by $iDivisor: $iDividend = quotient*$iDivisor + remainder.
Argument Description
integer $iDividend This is the number that is being divided.
integer $iDivisor This is the number that is the divisor.
is_finite()
bool is_finite(double $dNumber)
This function returns TRUE if $dNumber is not infinite. Otherwise, it returns FALSE.
Argument Description
double $dNumber This is the number whose value is being tested.
is_infinite()
bool is_infinite(double $dNumber)
This function returns TRUE if $dNumber is infinite. Otherwise, it returns FALSE.
Argument Description
double $dNumber This is the number whose value is being tested.
is_nan()
bool is_nan(double $dNumber)
This function returns TRUE if $dNumber is not a number (NAN). Otherwise, it returns FALSE.
Argument Description
double $dNumber This is the number whose value is being tested.
max()
various max(various $qaNumber, ...)
This function maximum value of a set of values that are passed into it. The arguments may be of double or integer type and the result with have the same type. The function can take any number of arguments or it can take an array and return the largest value in the array. Argument types should not be mixed.
Argument Description
double $dNumber This is a value that is passed into the function.
min()
various min(various $qaNumber, ...)
This function minimum value of a set of values that are passed into it. The arguments may be of double or integer type and the result with have the same type. The function can take any number of arguments or it can take an array and return the smallesst value in the array. Argument types should not be mixed.
Argument Description
double $dNumber This is a value that is passed into the function.
pi()
double pi()
This function returns the approximate value of pi, which is the same as the constant M_PI.
rad2deg()
double rad2deg(double $dRadians)
This function returns the value of $dRadians converted to degrees, essentially multiplication by 180/pi.
Argument Description
double $dRadians This is a value oon radians.
round()
double round(double $dNumber, int $iPrecision = 0, int $iMode = PHP_ROUND_HALF_UP)
This function returns value of $dNumber rounded to the specified precision via the method specified by $iMode.
Argument Description
double $dNumber This is the number to be rounded.
int $iPrecision This specifies the number of digits after the decimal point in the returned value.
int $iMode This specifies the rounding method:
  • PHP_ROUND_HALF_UP - the .5 value always goes up
  • PHP_ROUND_HALF_DOWN - the .5 value always goes down
  • PHP_ROUND_HALF_EVEN - the .5 value always goes toward the even value
  • PHP_ROUND_HALF_ODD - the .5 value always goes toward the odd value
sqrt()
double sqrt(double $dNumber)
This function returns the square root of $dNumber. The domain of the function is [0, ∞) and the range is [0, ∞).
Argument Description
double $dNumber This is the independent variable value.
 
 

© 2007–2024 XoaX.net LLC. All rights reserved.