Skip to content
Related Articles

Related Articles

Scala Float round() method with example
  • Last Updated : 29 Oct, 2019
GeeksforGeeks - Summer Carnival Banner

The round() method is utilized to return the rounded value of the specified float value. If the float value is 5.5 or greater than 5.5 till 5.9, then it will returns 6 otherwise 5 if the float value is 5.0 or till 5.4

Method Definition: (Float_Value).round

Return Type: It returns the rounded value of the specified float value.

Example #1:




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



5

Example #2:




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

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :