Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Scala Int round() method with example

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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:




// Scala program of Int round
// method 
    
// Creating object 
object GfG 
{  
    
    // Main method 
    def main(args:Array[String]) 
    
        
        // Applying round method 
        val result = (5).round
            
            
        // Displays output 
        println(result) 
        
    
}  

Output:

5

Example #2:




// Scala program of Int round
// method 
    
// Creating object 
object GfG 
{  
    
    // Main method 
    def main(args:Array[String]) 
    
        
        // Applying round method 
        val result = (5.8).round
            
            
        // Displays output 
        println(result) 
        
    

Output:

6

My Personal Notes arrow_drop_up
Last Updated : 30 Jan, 2020
Like Article
Save Article
Similar Reads