PHP Math Functions

PHP consists several built-in Math functions and constants which helps to perform mathematical operations such as simple additions or subtraction to advanced calculations. The PHP math functions are part of the PHP core. Some of the PHP math functions are as follows :

  • abs() : Return the absolute (positive) value of a number.
  • ceil() : Return a number up to the nearest integer.
  • bindec() : Converts a binary number to a decimal 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.
  • floor() : Rounds a number down to the nearest integer.
  • hexdec() : Converts a hexadecimal number to a decimal number.
  • max() : Returns the highest value in an array, or the highest value of several specified values.
  • min() : Returns the lowest value in an array, or the lowest value of several specified values.
  • pi() : Returns the value of PI.
  • pow() : Returns x raised to the power of y.
  • rand() : Generates a random integer.

Next Topic :