XXVII. Mathematical functions

Introduction

These math functions will only handle values within the range of the long and double types on your computer. If you need to handle bigger numbers, take a look at the arbitrary precision math functions.

Math constants

The following values are defined as constants in PHP by the math extension:

Table 1. Math constants

ConstantValueDescription
M_PI3.14159265358979323846The value of ¶ (pi)

Table of Contents
Abs — absolute value
Acos — arc cosine
Asin — arc sine
Atan — arc tangent
Atan2 — arc tangent of two variables
base_convert — convert a number between arbitrary bases
BinDec — binary to decimal
Ceil — round fractions up
Cos — cosine
DecBin — decimal to binary
DecHex — decimal to hexadecimal
DecOct — decimal to octal
Exp — e to the power of...
Floor — round fractions down
getrandmax — show largest possible random value
HexDec — hexadecimal to decimal
Log — natural logarithm
Log10 — base-10 logarithm
max — find highest value
min — find lowest value
mt_rand — generate a better random value
mt_srand — seed the better random number generator
mt_getrandmax — show largest possible random value
number_format — format a number with grouped thousands
OctDec — octal to decimal
pi — get value of pi
pow — exponential expression
rand — generate a random value
round — Rounds a float.
Sin — sine
Sqrt — square root
srand — seed the random number generator
Tan — tangent