Open In App

Scala Int toFloat() method with example

The toFloat() method is utilized to convert the specified int number into float data type value.

Method Definition: (Number).toFloat



Return Type: It returns the converted float datatype value.

Example #1:




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

Output:

1.0

Example #2:




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

Output:
12.0

Article Tags :