在 Julia 中获取绝对值的平方 – abs2() 方法
abs2()
是 julia 中的内置函数,用于返回指定数字x的绝对值的平方。
Syntax: abs2(x)
Parameters:
- x: Specified value.
Returns: It returns square of the absolute value of the specified number x.
示例 1:
# Julia program to illustrate
# the use of abs2() method
# Getting square of absolute value
# of the specified number x
println(abs2(0))
println(abs2(2))
println(abs2(-5))
输出:
0
4
25
示例 2:
# Julia program to illustrate
# the use of abs2() method
# Getting square of absolute value
# of the specified number x
println(abs2(0))
println(abs2(-2.7))
println(abs2(-2.9))
println(abs2(0.7))
println(abs2(-0.2))
println(abs2(22))
输出:
0
7.290000000000001
8.41
0.48999999999999994
0.04000000000000001
484