Related Tags

julia
communitycreator

# How to use the abs() method in Julia

Programming Bytes

### Overview

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.

### Syntax

abs(x)
Julia abs function Syntax

### Parameters

x: The value for which the absolute value is to be found.

### Return value

The absolute value of the specified value will be returned.

### Code

The code below demonstrates how to use the abs method.

## find abs of 10
println( "abs(10) => $(abs(10))") ## find abs of -3 println( "abs(-3) =>$(abs(-3))")

## find abs of -3.6
println( "abs(-3.6) => \$(abs(-3.6))")
Using the abs method

### Explanation

• Line 2: We use the abs method with 10 as an argument. The abs(10) will return 10.
• Line 5: We use the abs method with -3 as an argument. The abs(-3)will return 3.
• Line 8: We use the abs method with 3.6 as an argument. The abs(-3.6) will return 3.6.

RELATED TAGS

julia
communitycreator

CONTRIBUTOR

Programming Bytes
RELATED COURSES

View all Courses

Keep Exploring

Learn in-demand tech skills in half the time