BigInteger类的xor()方法 (BigInteger Class xor() method)

  • xor() method is available in java.math package.

    xor()方法在java.math包中可用。

  • xor() method is used to perform xor operation between this BigInteger and the given BigInteger and we all know when we perform xor so same bits represent 0 and different bits represents 1 and it returns negative BigInteger when any one of the value in [(this BigInteger) , (BigInteger val)] is negative.

    xor()方法用于在此BigInteger与给定的BigInteger之间执行xor运算,我们都知道执行xor时,相同的位表示0,不同的位表示1,并且当[[ BigInteger),((BigInteger val)]为负。

  • xor() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    xor()方法是一种非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • xor() method does not throw an exception at the time of performing xor.

    xor()方法在执行xor时不会引发异常。

Syntax:

句法:

    public BigInteger xor(BigInteger val);

Parameter(s):

参数:

  • BigInteger val – represents the value to perform xor with this BigInteger.

    BigInteger val –表示要对此BigInteger执行xor的值。

Return value:

返回值:

The return type of this method is BigInteger, it returns BigInteger that holds the value [(this BigInteger) xor (BigInteger val)].

此方法的返回类型为BigInteger ,它返回保存值[(this BigInteger)xor(BigInteger val)]的BigInteger。

Example:

例:

// Java program to demonstrate the example
// of BigInteger xor(BigInteger val) method of BigInteger
import java.math.*;
public class XOROfBI {public static void main(String args[]) {// Initialize two variables str1 and str2
String str1 = "10";
String str2 = "4";
// Initialize two BigInteger objects
BigInteger b_int1 = new BigInteger(str1);
BigInteger b_int2 = new BigInteger(str2);
System.out.println("b_int1: " + b_int1);
System.out.println("b_int2: " + b_int2);
// Here, this method xor(BigInteger) is used to
// perform xor (^) operation between
// this BigInteger b_int1 and the given BigInteger
// b_int2 like 10 ^ 4 so the binary representation
// of 10 is 1010 and for 4 is 0100 so when we perform
// (^) operation between bits it sets 1 when both the bits
// value are different otherwise it sets 0 so the result is
// (1010 ^ 0100 = 1110)
BigInteger xor_val = b_int1.xor(b_int2);
System.out.println("b_int1.xor(b_int2): " + xor_val);
}
}

Output

输出量

b_int1: 10
b_int2: 4
b_int1.xor(b_int2): 14

翻译自: https://www.includehelp.com/java/biginteger-xor-method-with-example.aspx

Java BigInteger类| xor()方法与示例相关推荐

  1. java annotation class,Java Class类 isAnnotation()方法及示例

    Class类isAnnotation()方法isAnnotation()方法在java.lang包中可用. isAnnotation()方法用于检查此Class对象是否表示注释类型. isAnnota ...

  2. java字符类型的返回值,Java字符类isWhitespace()方法及示例

    Character 类isWhitespace()法isWhitespace()方法在java.lang包中可用. isWhitespace()方法用于检查给定的char值是否为空格,但是它包含空格中 ...

  3. Java BigInteger类| 带示例的shiftLeft()方法

    BigInteger类shiftLeft()方法 (BigInteger Class shiftLeft() method) shiftLeft() method is available in ja ...

  4. Java BigInteger类| modInverse()方法与示例

    BigInteger类modInverse()方法 (BigInteger Class modInverse() method) modInverse() method is available in ...

  5. Java BigInteger类| and()方法与示例

    BigInteger类和()方法 (BigInteger Class and() method) and() method is available in java.math package. and ...

  6. Java BigInteger类| 带有示例的减去()方法

    BigInteger类减去()方法 (BigInteger Class subtract() method) subtract() method is available in java.math p ...

  7. Java BigInteger类| toByteArray()方法与示例

    BigInteger类testBit()方法 (BigInteger Class testBit() method) testBit() method is available in java.mat ...

  8. Java BigInteger类| nextProbablePrime()方法与示例

    BigInteger类nextProbablePrime()方法 (BigInteger Class nextProbablePrime() method) nextProbablePrime() m ...

  9. Java BigInteger类| hashCode()方法与示例

    BigInteger类hashCode()方法 (BigInteger Class hashCode() method) hashCode() method is available in java. ...

最新文章

  1. php中new运算符的作用,C++_C++编程中new运算符的使用学习教程,new运算符用作从自由存储为 typ - phpStudy...
  2. javaee后台适合用的编辑器插件
  3. SoftReference和WeakReference
  4. Navicat工具导出mySQL数据库某个视图结构的.sql脚本
  5. java json path_Java使用JSONPath解析JSON完整内容详解
  6. java日历事件处理_日历表的事件处理和管理(刘静)
  7. 微软免费软件项目DreamSpark更名为Microsoft Imagine
  8. Linux客户端权限,linux用户与权限使用方法
  9. vue内容横向循环滚动_Vue替代marquee标签超出宽度文字横向滚动效果
  10. pip install urllib3[secure] 报错 error: ffi.h: No such file or directory
  11. c语言槟编程把两个数交换,第三章管理信息系统技术基础.doc
  12. 使用HTML5,CSS3和jQuery增强网站用户体验
  13. DSP实验二c语言程序,实验1.2:编写一个以C语言为基础的DSP程序
  14. GIS:揭开你神秘的面纱
  15. hibernate 3中要注意的地方
  16. PreScan快速入门到精通第二讲PreScan功能介绍
  17. 大数据决策支持的优势
  18. Linux 编译debug内核
  19. 莫言2012诺贝尔奖颁奖词
  20. 2018/10/25 模拟赛 纸牌

热门文章

  1. 怎么做95置信区间图_这种动态的OD图怎么做?简单3步快速搞定
  2. inur new.php id,Cmsez(随易)全站系统 0day
  3. oracle树状排序,Oracle树状结构查询
  4. chrome 新的session 设置_为什么还是由这么多人搞不懂Cookie、Session、Token?
  5. 使用conda/pip安装pytorch 0.3.1教程(mac/windos/linux) pytorch 0.2.1
  6. Redis 核心技术与实战
  7. Linux环境下Flume的安装
  8. Redis(八):Zset有序集合数据类型详解
  9. linux扫描工具之nmap
  10. SharePoint CAML In Action——Part I