Getting the absolute value of a number in Julia – abs() Method
The abs()
is an inbuilt function in julia which is used to return the absolute value of the specified number x.
Syntax: abs(x)
Parameters:
- x: Specified value.
Returns: It returns the absolute value of the specified number x.
Example 1:
# Julia program to illustrate # the use of abs() method # Getting absolute value of the # specified number x println( abs ( 0 )) println( abs ( - 2.7 )) println( abs ( 2 )) |
chevron_right
filter_none
Output:
0 2.7 2
Example 2:
# Julia program to illustrate # the use of abs() method # Getting absolute value of the # specified number x println( abs ( 0 )) println( abs ( - 2.7 )) println( abs ( - 2.9 )) println( abs ( 0.7 )) println( abs ( - 0.2 )) println( abs ( - 22 )) |
chevron_right
filter_none
Output:
0 2.7 2.9 0.7 0.2 22