Open In App

Scala Long 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 long toDouble()
// method
  
// Creating object
object Test
{
  
    // Main method
    def main(args : Array[String])
    {
  
        // Implementing toDouble method
        val res = (3).toDouble
  
        // Displays output
        println(res)
    }
}

Output:



3.00

Example 2:




// Scala program of Long toDouble()
// method
  
// Creating object
object Test
{
  
    // Main method
    def main(args : Array[String])
    {
  
        // Implementing toDouble method
        val res = (9.8796).toDouble
  
        // Displays output
        println(res)
    }
}

Output:

9.8796

Article Tags :