带有示例的 Scala Long toDouble() 方法
toDouble() 方法用于将指定的数字转换为双精度数据类型值。
Method Definition: (Number).toDouble
Return Type: It returns the converted double datatype value.
示例 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)
}
}
输出:
3.00
示例 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)
}
}
输出:
9.8796