Open In App

Scala Char toFloat() method with example

Last Updated : 29 Oct, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
The toFloat() method is utilized to convert a stated character into float or its ASCII value of type float.
Method Definition: def toFloat: Float Return Type: It returns Float or ASCII value of the corresponding letter of type float.
Example: 1# Scala
// Scala program of toFloat()
// method

// Creating object
object GfG
{ 

    // Main method
    def main(args:Array[String])
    {
    
        // Applying toFloat method
        val result = 'A'.toFloat
        
        // Displays output
        println(result)
        
    }
} 
Output:
65.0
Example: 2# Scala
// Scala program of toFloat()
// method

// Creating object
object GfG
{ 

    // Main method
    def main(args:Array[String])
    {
    
        // Applying toFloat method
        val result = '7'.toFloat
        
        // Displays output
        println(result)
    
    }
} 
Output:
55.0

Next Article
Article Tags :

Similar Reads