Home »
Julia
abs2() Function with Example in Julia
Julia | abs2() function: In this tutorial, we are going to learn about the abs2() function with example in the Julia programming language.
Submitted by IncludeHelp, on April 04, 2020
Julia | abs2() function
abs2() function is a library function in Julia programming language, it is used to get the squared absolute value of the given signed integer.
Syntax:
abs2(val)
Parameter(s):
- val – represents a signed integer/value, whose squared absolute value to be found.
Return value:
The return type of this method is Int64, it returns the squared absolute value of val.
Example:
Input:
val = 0
Output:
abs2(val): 0
Input:
val = -10
Output:
abs2(val): 100
Input:
val = 10
abs2(val): 100
Program:
# abs2() Function with Example in Julia
val = 0
println("val: ", val)
println("abs2(val): ", abs2(val))
val = 10
println("val: ", val)
println("abs2(val): ", abs2(val))
val = -10
println("val: ", val)
println("abs2(val): ", abs2(val))
val = 10.23
println("val: ", val)
println("abs2(val): ", abs2(val))
val = -10.23
println("val: ", val)
println("abs2(val): ", abs2(val))
# printing the return type of abs2()
println("typeof(abs2(-10)): ", typeof(abs2(-10)))
Output
val: 0
abs2(val): 0
val: 10
abs2(val): 100
val: -10
abs2(val): 100
val: 10.23
abs2(val): 104.6529
val: -10.23
abs2(val): 104.6529
typeof(abs2(-10)): Int64