1
1
Fork 0
mirror of https://github.com/DualBrain/QB64.git synced 2023-11-19 13:10:13 +00:00
QB64-website/wiki/ABS.md
2022-12-24 19:12:43 -06:00

880 B

The ABS function returns the unsigned numerical value of a variable or literal value.

Syntax

positive = ABS(numericalValue)

Description

  • ABS always returns positive numerical values. The value can be any numerical type.
  • Often used to keep a value positive when necessary in a program.
  • Use SGN to determine a value's sign when necessary.
  • QB64 allows programs to return only positive _UNSIGNED variable values using a DIM or _DEFINE statement.

Example(s)

Finding the absolute value of positive and negative numerical values.


a = -6
b = -7
c = 8
IF a < 0 THEN a = ABS(a)
b = ABS(b)
c = ABS(c)
PRINT a, b, c 


 6        7        8

See Also