Scala Int abs() method with example
The abs() method is utilized to return the absolute value of the given integer value. The absolute value of any number is the magnitude of that number i.e, without any sign.
Method Definition: (Signed_Integer_Value).abs
Return Type: It return the absolute value of the given signed integer value.
Example #1:
object GfG
{
def main(args : Array[String])
{
val result = (- 5 ).abs
println(result)
}
}
|
Example #2:
object GfG
{
def main(args : Array[String])
{
val result = (+ 65 ).abs
println(result)
}
}
|
Last Updated :
03 Nov, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...