📜  斯卡拉字节^(x:字节):整数

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

斯卡拉字节^(x:字节):整数

在 Scala 中,Byte 是一个 8 位有符号整数(相当于 Java 的 byte 原始类型)。方法 ^(x:Byte) 方法用于返回此值和 x 的按位异或。

示例 #1:

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

输出:

108

示例 #2:

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

输出:

-117