From Liberty BASIC Family
Jump to navigation Jump to search
Supported in Just BASIC Supported in Liberty BASIC Not supported in Liberty BASIC 5 Not supported in Run BASIC


This function returns the absolute value of the given number or expression.
For negative values it will return the positive value.


  1. ABS(Number)


Most mathematical operations in BASIC can be performed on Literal Numbers, Numeric Variables or Numeric Expressions that consist of Literal Numbers, Numeric Variables or both.


Print ABS(2)
Print ABS(3.5)
Print ABS(-0.2)
Print ABS(2*1.5)

Produces: 2 3.5 0.2 3.0

Useful Procedures

Function SGN(number)
    ' This function returns the sign of a number:
    '    -1 ... negative number
    '     0 ... zero
    '     1 ... positive number

    If number <> 0 Then SGN = number / ABS(number)
End Function