Click or drag to resize

Abs Function

Return the absolute value of a numeric expression, regardless of its sign.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.08
Syntax
 FUNCTION Abs(
	nValue AS USUAL
) AS USUAL
View Source

Parameters

nValue
Type: Usual
The numeric expression to evaluate.

Return Value

Type: Usual
A positive number or 0.
Remarks
Absolute value is the same as <nValue> if <nValue> is greater than or equal to  0.  It is the negation of <nValue> if <nValue> is less than 0.  Abs() lets you get the difference between the magnitude of  two numbers, where magnitude is the distance from the origin or zero.
Examples
These examples show typical results from Abs():
X#
nNum1 := 100
nNum2 := 150
? nNum1 - nNum2                                // -50
? ABS(nNum1 - nNum2)                        //  50
? ABS(nNum2 - nNum1)                        //  50
? ABS(-12)                                        //  12
? ABS(0)                                        //  0
nSouth := -5
nNorth := 4
? ABS(nSouth) - ABS(nNorth)                // 1
? ABS(nSouth) > ABS(nNorth)                // TRUE
? nSouth > nNorth                        // FALSE
See Also