The abs(x)
method will return the absolute value of x
. The absolute value denotes the non-negative value of x
without regard to its sign.
abs(x)
x
: The value for which the absolute value is to be found.
The absolute value of the specified value will be returned.
The code below demonstrates how to use the abs
method.
## find abs of 10println( "abs(10) => $(abs(10))")## find abs of -3println( "abs(-3) => $(abs(-3))")## find abs of -3.6println( "abs(-3.6) => $(abs(-3.6))")
abs
method with 10
as an argument. The abs(10)
will return 10
.abs
method with -3
as an argument. The abs(-3)
will return 3
.abs
method with 3.6
as an argument. The abs(-3.6)
will return 3.6
.