Home >>PHP Math Functions

As a matter of fact we all are aware of the fact that PHP is generally a server side scripting language and is basically used for creating the dynamic web pages on the World Wide Web. PHP language is a web development language that delivers a number of built-in **PHP math functions** that basically helps in executing various operations at the time of dealing with the mathematical data.

This language has the very efficient support for the mathematical processing. In this process there is no need of the installation that generally aroused in order to use these functions. The **PHP math function** can basically handle the values that are within the range of integer and float types.

Mathematics functions or math function in short are the functions that are used very frequently in the scripts. There are various **PHP numeric functions** that are provided to take care of the addition, subtraction, multiplication and various other mathematical requirements.

In this tutorial, there are two major components of the PHP are discussed, one is the PHP math functions or PHP numeric functions and the other one is **PHP math constant** or it is also known as the **PHP numeric constant**. Let's get to know them one by one.

**Here is the list of the PHP math functions** depicted below that are widely used in order to perform the mathematical operations:

Function | Description |
---|---|

abs() | This function is used to return the absolute (positive) value of a number |

acos() | This function is used to return the arc cosine of a number |

acosh() | This function is used to return the inverse hyperbolic cosine of a number |

asin() | This function is used to return the arc sine of a number |

asinh() | This function PHP is used to return the inverse hyperbolic sine of a number |

atan() | This function is generally used to return the arc tangent of a number in radians |

atan2() | It is used to return the arc tangent of two variables x and y |

atanh() | It is used to return the inverse hyperbolic tangent of a number |

base_convert() | It is basically used to convert a number from one number base to another |

bindec() | It is basically used to convert a binary number to a decimal number |

ceil() | This function is used to round a number up to the nearest integer |

cos() | This function is used to return the cosine of a number |

cosh() | This function is used to return the hyperbolic cosine of a number |

decbin() | It is basically uses to convert a decimal number to a binary number |

dechex() | It is basically uses to convert a decimal number to a hexadecimal number |

decoct() | It is basically uses to convert a decimal number to an octal number |

deg2rad() | It is basically uses to convert a degree value to a radian value |

exp() | This function is used to calculate the exponent of e |

expm1() | This function is generally used to return exp(x) - 1 |

floor() | This function is generally used to round a number down to the nearest integer |

fmod() | This function is used to return the remainder of x/y |

getrandmax() | This function is used to return the largest possible value returned by rand() |

hexdec() | This function is used to convert a hexadecimal number to a decimal number |

hypot() | It is generally used to calculate the hypotenuse of a right-angle triangle |

intdiv() | This function is basically used to perform the integer division |

is_finite() | It is basically used to check whether a value is finite or not |

is_infinite() | It is basically used to check whether a value is infinite or not |

is_nan() | It is basically used to check whether a value is 'not-a-number' |

lcg_value() | This function is basically used to return a pseudo random number in a range between 0 and 1 |

log() | This function is basically used to return the natural logarithm of a number |

log10() | This function is basically used to return the base-10 logarithm of a number |

log1p() | This function is basically used to return log(1+number) |

max() | This function is basically used to return the highest value in an array or it can be said that the highest value of various specified values |

min() | This function is basically used to return the lowest value in an array or it can be said that the lowest value of various specified values |

mt_getrandmax() | This function is basically used to return the largest possible value returned by mt_rand() |

mt_rand() | It is the function that is used in order to generate a random integer using Mersenne Twister algorithm |

mt_srand() | It is the function that is used to seed the Mersenne Twister random number generator |

octdec() | This function is basically used to convert an octal number in to a decimal number |

pi() | This function is simply used to return the value of the PI |

pow() | This function is simply used to return x raised to the power of y |

rad2deg() | This function is used to convert a radian value to a degree value |

rand() | It is the function that is used in order to generate a random integer |

round() | This function is generally used to round a floating-point number |

sin() | This function is simply used to return the sine of a number |

sinh() | This function is simply used to return the hyperbolic sine of a number |

sqrt() | This function is simply used to return the square root of a number |

srand() | It is the function that is used to seed the random number generator |

tan() | This function is basically used to return the tangent of a number |

tanh() | This function is basically used to return the hyperbolic tangent of a number |

There are various **PHP numeric constants** that are used in the PHP languages in order to perform the mathematical operations that are depicted below along with their value and a short description:

Constant | Value | Description |
---|---|---|

INF | INF | This is the constant that symbolizes the infinite. |

M_E | 2.7182818284590452354 | This consonant is simply used to return e |

M_EULER | 0.57721566490153286061 | This consonant is basically used to return Euler constant |

M_LNPI | 1.14472988584940017414 | It is the consonant that is used to return the natural logarithm of PI: log_e(pi) |

M_LN2 | 0.69314718055994530942 | It is the consonant that is used to return the natural logarithm of 2: log_e 2 |

M_LN10 | 2.30258509299404568402 | It is the consonant that is used to return the natural logarithm of 10: log_e 10 |

M_LOG2E | 1.4426950408889634074 | This consonant is basically used to return the base-2 logarithm of E: log_2 e |

M_LOG10E | 0.43429448190325182765 | This consonant is simply used to return the base-10 logarithm of E: log_10 e |

M_PI | 3.14159265358979323846 | This consonant is simply used to return the value of the Pi |

M_PI_2 | 1.57079632679489661923 | This consonant is basically used to return the value of Pi/2 |

M_PI_4 | 0.78539816339744830962 | This consonant is basically used to return the value of Pi/4 |

M_1_PI | 0.31830988618379067154 | This consonant is basically used to return the value of 1/Pi |

M_2_PI | 0.63661977236758134308 | This consonant is basically used to return the value of 2/Pi |

M_SQRTPI | 1.77245385090551602729 | In PHP this numeric consonant is used to return the square root of PI: sqrt(pi) |

M_2_SQRTPI | 1.12837916709551257390 | In PHP this numeric consonant is used to return the 2/square root of PI: 2/sqrt(pi) |

M_SQRT1_2 | 0.70710678118654752440 | This consonant is basically used to return the square root of 1/2: 1/sqrt(2) |

M_SQRT2 | 1.41421356237309504880 | This consonant is basically used to return the square root of 2: sqrt(2) |

M_SQRT3 | 1.73205080756887729352 | This consonant is basically used to return the square root of 3: sqrt(3) |

NAN | NAN | This PHP numeric constant is described as Not A Number |

PHP_ROUND_HALF_UP | 1 | This consonant is basically used to round halves up |

PHP_ROUND_HALF_DOWN | 2 | This consonant is basically used to round halves down |

PHP_ROUND_HALF_EVEN | 3 | This consonant is basically used to round halves to even numbers |

PHP_ROUND_HALF_ODD | 4 | This consonant is basically used to round halves to odd numbers |

No Sidebar ads