Scala Int round() method with example
Last Updated :
30 Jan, 2020
The round() method is utilized to return the rounded value of the specified int value. This method is used to avoid accidental loss of precision from a detour through Float.
Method Definition: def round: Int
Return Type: It returns the rounded value of the specified int value.
Example #1:
object GfG
{
def main(args : Array[String])
{
val result = ( 5 ).round
println(result)
}
}
|
Example #2:
object GfG
{
def main(args : Array[String])
{
val result = ( 5.8 ).round
println(result)
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...