Scala Float floor() method with example
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
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.