ÍøÂçѧԺ w3popÉçÇø ÍøÂç×ÊÔ´ ITÐÂÎÅ

w3pop.com :: ÍøÂçѧԺ :: PHP :: PHP Math

»áÔ±µÇ½

ÕʺÅ

ÃÜÂë

»Ø´ð

¼ÇסÃÜÂë

Íü¼ÇÃÜÂë? ×¢²á

PHP
PHP Libxml
PHP Math
PHP Misc
PHP MySQL
PHP SimpleXML
PHP String
PHP XML
PHP Zip
PHP Mail
ÓÃPHP5µÄDirector..
PHP ×èÖ¹SQL×¢ÈëÊ..
PHP5ÃæÏò¶ÔÏó - »..
PHP5ÃæÏò¶ÔÏó - »..
PHP5ÃæÏò¶ÔÏó - »..
PHP5ÃæÏò¶ÔÏó - »..
PHP5ÃæÏò¶ÔÏó - »..
php5ÃæÏò¶ÔÏó - »..
php5ÃæÏò¶ÔÏó - »..
ÓÃPHP¿ØÖÆÓû§µÄä..
PHP PDO ѧϰ±Ê¼Ç

PHP Math


×÷Õß:w3pop.com ·­Òë/ÕûÀí:w3pop.com ·¢²¼:2007-04-28 ä¯ÀÀ:4141 :: ::

PHP Math Introduction
PHPÊýѧ½éÉÜ

The math functions can handle values within the range of integer and float types.
ÕâЩÊýѧº¯Êý½öÄÜ´¦ÀíÔÚÄã¼ÆËã»úÉÏ integer ºÍ float ·¶Î§ÄÚµÄÖµ


Installation
°²×°

The math functions are part of the PHP core. There is no installation needed to use these functions.
±¾º¯Êý¿â×÷Ϊ PHP Äں˵ÄÒ»²¿·Ö£¬²»Óð²×°¾ÍÄÜʹÓá£


PHP Math Functions
PHPÊýѧº¯Êý

PHP: indicates the earliest version of PHP that supports the function.
PHP£º×îÔçÖ§³ÖÕâЩº¯ÊýµÄPHP°æ±¾

Function Description PHP
abs() Returns the absolute value of a number
¾ø¶ÔÖµ
3
acos() Returns the arccosine of a number
·´ÓàÏÒ
3
acosh() Returns the inverse hyperbolic cosine of a number
·´Ë«ÇúÓàÏÒ
4
asin() Returns the arcsine of a number
·´ÕýÏÒ
3
asinh() Returns the inverse hyperbolic sine of a number
·´Ë«ÇúÕýÏÒ
4
atan() Returns the arctangent of a number as a numeric value between -PI/2 and PI/2 radians
·´ÕýÇÐ
3
atan2() Returns the angle theta of an (x,y) point as a numeric value between -PI and PI radians
Á½¸ö²ÎÊýµÄ·´ÕýÇÐ
3
atanh() Returns the inverse hyperbolic tangent of a number
·´Ë«ÇúÕýÇÐ
4
base_convert() Converts a number from one base to another
ÔÚÈÎÒâ½øÖÆÖ®¼äת»»Êý×Ö
3
bindec() Converts a binary number to a decimal number
¶þ½øÖÆ×ª»»ÎªÊ®½øÖÆ
3
ceil() Returns the value of a number rounded upwards to the nearest integer
½øÒ»·¨È¡Õû
3
cos() Returns the cosine of a number
ÓàÏÒ
3
cosh() Returns the hyperbolic cosine of a number
Ë«ÇúÓàÏÒ
4
decbin() Converts a decimal number to a binary number
Ê®½øÖÆ×ª»»Îª¶þ½øÖÆ
3
dechex() Converts a decimal number to a hexadecimal number
Ê®½øÖÆ×ª»»ÎªÊ®Áù½øÖÆ
3
decoct() Converts a decimal number to an octal number
Ê®½øÖÆ×ª»»Îª°Ë½øÖÆ
3
deg2rad() Converts a degree to a radian number
½«½Ç¶Èת»»Îª»¡¶È
3
exp() Returns the value of Ex
¼ÆËã e£¨×ÔÈ»¶ÔÊýµÄµ×£©µÄÖ¸Êý
3
expm1() Returns the value of Ex - 1
·µ»Ø exp(number) - 1£¬ÉõÖÁµ± number µÄÖµ½Ó½üÁãÒ²ÄܼÆËã³ö׼ȷ½á¹û
4
floor() Returns the value of a number rounded downwards to the nearest integer
ÉáÈ¥·¨È¡Õû
3
fmod() Returns the remainder (modulo) of the division of the arguments
·µ»Ø³ý·¨µÄ¸¡µãÊýÓàÊý
4

getrandmax()

Returns the maximum random number that can be returned by a call to the rand() function
ÏÔÊ¾Ëæ»úÊý×î´óµÄ¿ÉÄÜÖµ
3
hexdec() Converts a hexadecimal number to a decimal number
Ê®Áù½øÖÆ×ª»»ÎªÊ®½øÖÆ
3
hypot() Returns the length of the hypotenuse of a right-angle triangle
¼ÆËãÒ»Ö±½ÇÈý½ÇÐεÄб±ß³¤¶È
4
is_finite() Returns true if a value is a finite number
ÅжÏÊÇ·ñΪÓÐÏÞÖµ
4
is_infinite() Returns true if a value is an infinite number
ÅжÏÊÇ·ñΪÎÞÏÞÖµ
4
is_nan() Returns true if a value is not a number
ÅжÏÊÇ·ñΪºÏ·¨ÊýÖµ
4
lcg_value() Returns a pseudo random number in the range of (0,1)
×éºÏÏßÐÔͬÓà·¢ÉúÆ÷
4
log() Returns the natural logarithm (base E) of a number
×ÔÈ»¶ÔÊý
3
log10() Returns the base-10 logarithm of a number
ÒÔ 10 Ϊµ×µÄ¶ÔÊý
3
log1p() Returns log(1+number)
·µ»Ø log(1 + number)£¬ÉõÖÁµ± number µÄÖµ½Ó½üÁãÒ²ÄܼÆËã³ö׼ȷ½á¹û
4
max() Returns the number with the highest value of two specified numbers
ÕÒ³ö×î´óÖµ
3
min() Returns the number with the lowest value of two specified numbers
ÕÒ³ö×îСֵ
3
mt_getrandmax() Returns the largest possible value that can be returned by mt_rand()
ÏÔÊ¾Ëæ»úÊýµÄ×î´ó¿ÉÄÜÖµ
3
mt_rand() Returns a random integer using Mersenne Twister algorithm
²úÉúÒ»¸öËæ»úÕûÊý using Mersenne Twister algorithm Éú³É¸üºÃµÄËæ»úÊý
3
mt_srand() Seeds the Mersenne Twister random number generator
²¥ÏÂÒ»¸ö¸üºÃµÄËæ»úÊý·¢ÉúÆ÷ÖÖ×Ó
3
octdec() Converts an octal number to a decimal number
°Ë½øÖÆ×ª»»ÎªÊ®½øÖÆ
3
pi() Returns the value of PI
µÃµ½Ô²ÖÜÂÊÖµ
3
pow() Returns the value of x to the power of y
·µ»ØÖ¸Êý±í´ïʽµÄÖµ£¬¼´£ºxµÄy´Î·½
3
rad2deg() Converts a radian number to a degree
½«»¡¶ÈÊýת»»ÎªÏàÓ¦µÄ½Ç¶ÈÊý
3
rand() Returns a random integer
²úÉúÒ»¸öËæ»úÕûÊý
3
round() Rounds a number to the nearest integer
¶Ô¸¡µãÊý½øÐÐËÄÉáÎåÈëÈ¡Õû
3
sin() Returns the sine of a number
ÕýÏÒ
3
sinh() Returns the hyperbolic sine of a number
Ë«ÇúÕýÏÒ
4
sqrt() Returns the square root of a number
ƽ·½¸ù
3
srand() Seeds the random number generator
²¥ÏÂËæ»úÊý·¢ÉúÆ÷ÖÖ×Ó
3
tan() Returns the tangent of an angle
ÕýÇÐ
3
tanh() Returns the hyperbolic tangent of an angle
Ë«ÇúÕýÇÐ
4


PHP Math Constants
PHPÊýѧ³£Á¿

PHP: indicates the earliest version of PHP that supports the constant.
PHP£º×îÔçÖ§³ÖÕâЩ³£Á¿µÄPHP°æ±¾

Constant
³£Á¿
Description
˵Ã÷
PHP
M_E Returns e (approx. 2.718)
·µ»Ø×ÔÈ»¶ÔÊýµ×£¨Öµ´óԼΪ£º2.718£©
4
M_EULER Returns Euler's constant (approx. 0.577)
Å·À­³£Êý£¨Öµ´óԼΪ£º0.57721566490153286061£©
4
M_LNPI

Returns the natural logarithm of PI (approx. 1.144)
·µ»ØPIµÄ×ÔÈ»¶ÔÊý£¨Öµ´óԼΪ£º1.144£©

4
M_LN2 Returns the natural logarithm of 2 (approx. 0.693)
·µ»Ø2µÄ×ÔÈ»¶ÔÊý£¨Öµ´óԼΪ£º0.693£©
4
M_LN10 Returns the natural logarithm of 10 (approx. 2.302)
·µ»Ø10µÄ×ÔÈ»¶ÔÊý£¨Öµ´óԼΪ£º2.302£©
4
M_LOG2E Returns the base-2 logarithm of E (approx. 1.442)
·µ»ØE¶ÔÓ¦µÄÒÔ2Ϊµ×µÄ×ÔÈ»¶ÔÊý£¨Öµ´óԼΪ£º1.442£©
4
M_LOG10E Returns the base-10 logarithm of E (approx. 0.434)
·µ»ØE¶ÔÓ¦µÄÒÔ10Ϊµ×µÄ×ÔÈ»¶ÔÊý£¨Öµ´óԼΪ£º0.434£©
4
M_PI Returns PI (approx. 3.14159)
·µ»ØPI£¨Öµ´óԼΪ£º3.14159£©
3
M_PI_2 Returns PI/2 (approx. 1.570)
·µ»ØPI/2£¨Öµ´óԼΪ£º1.570£©
4
M_PI_4 Returns PI/4 (approx. 0.785)
·µ»ØPI/4£¨Öµ´óԼΪ£º0.785£©
4
M_1_PI Returns 1/PI (approx. 0.318)
·µ»Ø1/PI£¨Öµ´óԼΪ£º0.318£©
4
M_2_PI Returns 2/PI (approx. 0.636)
·µ»Ø2/PI£¨Öµ´óԼΪ£º0.636£©
4
M_SQRTPI Returns the square root of PI (approx. 1.772)
·µ»ØPIµÄƽ·½¸ù£¨Öµ´óԼΪ£º1.772£©
4
M_2_SQRTPI Returns 2/square root of PI (approx. 1.128)
·µ»ØPIµÄƽ·½¸ùµÄÁ½±¶µ¹Êý£¨Öµ´óԼΪ£º1.128£©
4
M_SQRT1_2 Returns the square root of 1/2 (approx. 0.707)
·µ»Ø1/2µÄƽ·½¸ù£¨Öµ´óԼΪ£º0.707£©
4
M_SQRT2 Returns the square root of 2 (approx. 1.414)
·µ»Ø2µÄƽ·½¸ù£¨Öµ´óԼΪ£º1.414£©
4
M_SQRT3 Returns the square root of 3 (approx. 1.732)
·µ»Ø3µÄƽ·½¸ù£¨Öµ´óԼΪ£º1.732£©
4

ÆÀÂÛ (0) All