ABS()

Description

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

Syntax

  1. ABS(Number)

Hints

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

Example

Print ABS(2)
Print ABS(3.5)
Print ABS(-0.2)
Print ABS(2*1.5)
End
Produces: 2 3.5 0.2 3.0

Useful Functions

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