Open In App

Scala Float floor() method with example

Last Updated : 29 Oct, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

The floor() method is utilized to returns a float number which is less than or equal to the given float number.

Method Definition: (Float_Number).floor

Return Type: It returns a float number which is less than or equal to the given float number.

Example #1:




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


Output:

5.0

Example #2:




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


Output:

-4.0


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads