41 of 410 menu

The abs Function

The abs function calculates the absolute value of a number, turning a negative into a positive.

Syntax

abs(number);

Example

Let's find the absolute value of the number -15:

<?php echo abs(-15); ?>

Code execution result:

15

See Also

  • the round function,
    which rounds a fraction according to mathematical rules
  • the ceil function,
    which rounds a fraction up
  • the floor function,
    which rounds a fraction down
byenru