Open In App

Getting the absolute value of a number in Julia – abs() Method

Last Updated : 21 Apr, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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))


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))


Output:

0
2.7
2.9
0.7
0.2
22

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads