Skip to content
Related Articles

Related Articles

Scala Char toFloat() method with example
  • Last Updated : 29 Oct, 2019

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



My Personal Notes arrow_drop_up
Recommended Articles
Page :