Open In App

Scala Float toDouble() method with example

The toDouble() method is utilized to convert the specified number into double datatype value.

Method Definition: (Number).toDouble



Return Type: It returns the converted double datatype value.

Example #1:




// Scala program of Float toDouble()
// method
  
// Creating object
object GfG
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying toDouble method
        val result = (1).toDouble
          
        // Displays output
        println(result)
      
    }

Output:

1.0

Example #2:




// Scala program of Float toDouble()
// method
  
// Creating object
object GfG
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying toDouble method
        val result = (9.5467).toDouble
          
        // Displays output
        println(result)
      
    }

Output:
9.5467

Article Tags :