📜  Scala字节+(x:浮点数):浮点数

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

Scala字节+(x:浮点数):浮点数

在 Scala 中,Byte 是一个 8 位有符号整数(相当于 Java 的 byte 原始类型)。方法 +(x:Float) 方法用于返回该值乘以 x 的总和

示例 #1:

// Scala program of Byte +(x: Float)
// method 
  
// Creating object 
object GfG 
{ 
  
    // Main method 
    def main(args:Array[String]) 
    { 
      
        // Applying Byte +(x: Float) function 
        val result = (167.toByte).+(125:Float) 
          
        // Displays output 
        println(result) 
      
    } 
} 

输出:

36.0

示例 #2:

// Scala program of Byte +(x: Float)
// method 
  
// Creating object 
object GfG 
{ 
  
    // Main method 
    def main(args:Array[String]) 
    { 
      
        // Applying Byte +(x: Float) function 
        val result = (167.toByte).+(2:Float) 
          
        // Displays output 
        println(result) 
      
    } 
} 

输出:

-87.0