📜  Scala Byte toDouble() 方法

📅  最后修改于: 2022-05-13 01:55:30.621000             🧑  作者: Mango

Scala Byte toDouble() 方法

在 Scala 中,Byte 是一个 8 位有符号整数(相当于 Java 的 byte 原始类型)。 toDouble() 方法用于将指定的数字转换为 Double 数据类型值。

示例 #1:

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

输出:

13.0

示例 #2:

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

输出:

123.0