Open In App

Scala Char toFloat() method with example

Last Updated : 29 Oct, 2019
Improve
Improve
Like Article
Like
Save
Share
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 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 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


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

Similar Reads