Open In App

Scala Long toDouble() method with example

Last Updated : 03 Nov, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads