Abs() (PlayBasic)

( PlayBasic 1.61 )

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

Syntax

num = Abs ( x )

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

Description

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.

Example

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

Print Abs(42)
Print Abs(-42)
Sync
WaitKey

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.