带有示例的 Scala Char toFloat() 方法
toFloat()方法用于将指定字符转换为浮点数或浮点类型的 ASCII 值。
Method Definition: def toFloat: Float
Return Type: It returns Float or ASCII value of the corresponding letter of type float.
示例: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)
}
}
输出:
65.0
示例: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)
}
}
输出:
55.0