xHarbour Reference Documentation > Function Reference |
Returns the absolute value of a numeric expression.
Abs( <nExpression> ) --> nPositive
The function returns the absolute value of the passed argument. The result is always greater than or equal to zero.
The function removes the minus sign from negative numeric values and leaves non-negative values unchanged. This allows for determining the magnitude of numbers regardless of their sign.
See also: | Exp(), Int(), Log(), Max(), Min() |
Category: | Numeric functions |
Source: | rtl\abs.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example demonstrates results from Abs() PROCEDURE Main() LOCAL nVal1 := 200 LOCAL nVal2 := 900 ? nVal1 - nVal2 // result: -700 ? Abs( nVal1 - nVal2 ) // result: 700 ? Abs( nVal2 - nVal1 ) // result: 700 ? Abs( 0 ) // result: 0 ? Abs( -700 ) // result: 700 RETURN NIL
http://www.xHarbour.com