Abs() (PlayBasic)

( PlayBasic 1.61 )

Abs - make a negative number positive (return absolute value)


num = Abs ( x )

  • num - returned positive number.
  • x - number to change to positive


Abs() changes a negative number to a positive number. If the number is already positive, it simply returns the number as is. It does this by returning the number's absolute value, or distance from zero.


In the example code below, both numbers are printed as positive 42.

Print Abs(42)
Print Abs(-42)

Related Pages

  • GetSign() - check if a number is negative
  • Neg() - reverse the sign of a number
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution 2.5 License.