![]() |
|
PHP Mathematical Functions. Free online PHP and MySQL Web Database Programming Tutorial... |
| Lessons | PHP Mathematical Functions |
|
|
The ceil() function rounds a fraction up to the next highest integer. Its syntax follows: ceil(number); floor() The floor() function rounds a fraction down to the next lowest integer. Its syntax follows: floor(number); pow() We use this function to raise a number to the given exponent. Its syntax follows: pow(number, exponent); rand() This function is used to generate a random value between two given numbers. Its syntax follows: rand(min, max); round() This function rounds a fraction to the next highest or the next lowest integer. Its syntax follows: round(number); sqrt() The sqrt() function returns the square root of the argument number. Its syntax follows: sqrt(number); decbin() and bindec() The decbin() function converts decimal numbers to binary numbers and the bindec() function converts binary numbers to decimal numbers. Their syntax follows: decbin(decimalNumber); bindec(binaryNumber); dechex() and hexdec() The dechex() and hexdec() functions are used to convert decimal numbers to hexadecimal numbers and hexadecimal numbers to decimal numbers, respectively. Their syntax follows: dechex(decimalNumber); hexdec(HexaDecNumber); decoct() and octdec() We use the decoct() and octdec() functions to convert decimal numbers to octal and the octal numbers to decimal numbers, respectively. The syntax of these functions follows: decoct(decimalNumber); octdec(OctalNumber); |