Scala Float abs() method with example
Last Updated :
29 Oct, 2019
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: def abs: Float
Return Type: It return the absolute value of the given integer value.
Example #1:
object GfG
{
def main(args : Array[String])
{
val result = (- 5.4 ).abs
println(result)
}
}
|
Example #2:
object GfG
{
def main(args : Array[String])
{
val result = ( 3.8 ).abs
println(result)
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...