The abs() method returns the absolute value of the given value.
Example
abs() Syntax
The syntax of the abs() method is:
abs(num)
abs() Parameters
The abs() method takes one parameter
- num - a signed number
abs() Return Values
The abs() method returns the absolute value of num.
Example: Swift Double abs()
Output
Absolute value of -20 is: 20 Absolute value of -20 is: 33.33
Here, we have used the abs() method to find the absolute value of the given numbers: value1 and value2.