PHP 5 Math function

Source: Internet
Author: User
Tags base 10 logarithm natural logarithm rounds square root value of pi

PHP 5Math function Introduction to PHP Math

The Math function can handle values in the range of integers and float.

Installation

The PHP Math function is part of the PHP core. These functions can be used without installation.

PHP 5 Math function
function Description
ABS () Returns the absolute value of a number.
ACOs () Returns the inverse cosine of a number.
Acosh () Returns the inverse hyperbolic cosine of a number.
ASIN () Returns the inverse of a number of strings.
Asinh () Returns the inverse hyperbolic sine of a number.
Atan () Returns the inverse tangent of a number.
ATAN2 () Returns the inverse tangent of two variables x and Y.
Atanh () Returns the inverse hyperbolic tangent of a number.
Base_convert () Converts a number between arbitrary binaries.
Bindec () Converts a binary number into a decimal number.
Ceil () Rounds up to the nearest integer.
cos () Returns the cosine of a number.
Cosh () Returns the hyperbolic cosine of a number.
Decbin () Converts a decimal number to a binary number.
Dechex () Converts a decimal number to a hexadecimal number.
DECOCT () Converts a decimal number to an octal number.
Deg2rad () Converts the angle value to a radian value.
EXP () Returns the value of Ex.
EXPM1 () Returns the value of the Ex-1.
Floor () Rounds down to the nearest integer.
Fmod () Returns the remainder of the floating point number for X/Y.
Getrandmax () Returns the maximum possible value for the random number displayed by calling the rand () function.
Hexdec () Converts the hexadecimal number to a decimal number.
Hypot () Calculates the hypotenuse length of the right triangle.
Is_finite () Determines whether it is a finite value.
Is_infinite () Determines whether the value is infinite.
Is_nan () Determines whether it is a non-numeric value.
Lcg_value () Returns a pseudo-random number with a range of (0, 1).
Log () Returns the natural logarithm of a number (base E).
LOG10 () Returns the base 10 logarithm of a number.
LOG1P () Return log (1+number)
Max () Returns the maximum value in an array, or the maximum value in several specified values.
Min () Returns the minimum value in an array, or a minimum of several specified values.
Mt_getrandmax () Returns the maximum possible value of the random number displayed by calling the Mt_rand () function.
Mt_rand () Generates a random integer using the Mersenne Twister algorithm.
Mt_srand () Seeding Mersenne Twister random number generator.
Octdec () Converts the octal number to a decimal number.
Pi () Returns the value of pi.
POW () Returns the Y-side of X.
Rad2deg () Converts the Radian value to an angle value.
RAND () Returns a random integer.
Round () Rounding the floating-point numbers.
Sin () Returns the sine of a number.
Sinh () Returns the hyperbolic sine of a number.
sqrt () Returns the square root of a number.
Srand () Seeding random number generators.
Tan () Returns the tangent of a number.
Tanh () Returns the hyperbolic tangent of a number.

PHP 5 pre-defined Math constants

Constants value Description PHP version
Inf Inf Infinite PHP 4
M_e 2.7182818284590452354 Return E PHP 4
M_euler 0.57721566490153286061 Return Euler Constants PHP 4
M_lnpi 1.14472988584940017414 Returns the natural logarithm of pi: log_e (PI) PHP 5.2
M_ln2 0.69314718055994530942 Returns the natural logarithm of 2: log_e 2 PHP 4
M_ln10 2.30258509299404568402 Returns the natural logarithm of 10: log_e 10 PHP 4
m_log2e 1.4426950408889634074 Returns the base 2 logarithm of E: log_2 E PHP 4
m_log10e 0.43429448190325182765 Returns the base 10 logarithm of E: log_10 E PHP 4
M_pi 3.14159265358979323846 Return Pi PHP 4
M_pi_2 1.57079632679489661923 Back to PI/2 PHP 4
M_pi_4 0.78539816339744830962 Back to Pi/4 PHP 4
M_1_pi 0.31830988618379067154 Back to 1/pi PHP 4
M_2_pi 0.63661977236758134308 Back to 2/pi PHP 4
M_sqrtpi 1.77245385090551602729 Returns the square root of pi: sqrt (pi) PHP 5.2
M_2_sqrtpi 1.12837916709551257390 Returns the 2/square root of pi: 2/sqrt (PI) PHP 4
M_sqrt1_2 0.70710678118654752440 Returns the square root of 1/2:1/sqrt (2) PHP 4
M_sqrt2 1.41421356237309504880 Returns the square root of 2: sqrt (2) PHP 4
M_sqrt3 1.73205080756887729352 Returns the square root of 3: sqrt (3) PHP 5.2
NAN NAN Not a number PHP 4
Php_round_half_up 1 Rounding up when you encounter a condition of. 5 PHP 5.3
Php_round_half_down 2 Rounding down when you encounter a condition of. 5 PHP 5.3
Php_round_half_even 3 When you encounter a situation of. 5, take even rounds PHP 5.3
Php_round_half_odd 4 Odd rounding when encountering. 5 cases PHP 5.3

PHP 5 Math function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.