Scala Float toFloat() method with example
The toFloat() method is utilized to converted the specified number into float value.
Method Definition: (Number).toFloat
Return Type: It returns the converted float value.
Example #1:
// Scala program of Float toFloat() // method // Creating object object GfG { // Main method def main(args : Array[String]) { // Applying toFloat method val result = ( 9 ).toFloat // Displays output println(result) } } |
Output:
9.0
Example #2:
// Scala program of Float toFloat() // method // Creating object object GfG { // Main method def main(args : Array[String]) { // Applying toFloat method val result = ( 0 ).toFloat // Displays output println(result) } } |
Output:
0.0
Example #3:
// Scala program of Float toFloat() // method // Creating object object GfG { // Main method def main(args : Array[String]) { // Applying toFloat method val result = ( 4.7 ).toFloat // Displays output println(result) } } |
Output:
4.7