BigInteger类testBit()方法 (BigInteger Class testBit() method)

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

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

  • testBit() method is used to convert this BigInteger to a byte [] that holds 2's complement denotation of this BigInteger and the array capacity is enough to represent this BigInteger with one extra bit for the sign.

    testBit()方法用于将该BigInteger转换为一个字节[],该字节持有此BigInteger的2的补码表示,并且数组容量足以用一个额外的符号表示此BigInteger。

  • testBit() 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.

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

  • testBit() method does not throw an exception at the time of converting this object to a byte array.

    在将此对象转换为字节数组时, testBit()方法不会引发异常。

Syntax:

句法:

    public byte[] toByteArray();

Parameter(s):

参数:

  • None

    没有

Return value:

返回值:

The return type of this method is byte[], it represents this BigInteger in terms of 2’s complement in byte array.

此方法的返回类型为byte [] ,它以字节数组中2的补码形式表示此BigInteger。

Example:

例:

// Java program to demonstrate the example
// of byte[] toByteArray() method of BigInteger
import java.math.*;
import java.util.*;
public class ToByteArrayOfBI {public static void main(String args[]) {// Initializes a variable str
String str = "145";
// Initializes a BigInteger object
BigInteger b_int = new BigInteger(str);
// returns the convert this BigInteger
// into a byte[] that contains 2's complement of
// this BigInteger
byte[] b_arr = b_int.toByteArray();
for (int i = 0; i < b_arr.length; ++i)
System.out.println("b_int.toByteArray(): " + b_arr[i] + " ");
}
}

Output

输出量

b_int.toByteArray(): 0
b_int.toByteArray(): -111

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

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

  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类| nextProbablePrime()方法与示例

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

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

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

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

    BigInteger类isProbablePrime()方法 (BigInteger Class isProbablePrime() method) isProbablePrime() method ...

最新文章

  1. javascript十六进制数字和ASCII字符之间转换
  2. 第十一天 • 库塔山植物园
  3. 大盘点|卷积神经网络必读的 100 篇经典论文,包含检测 / 识别 / 分类 / 分割多个领域
  4. mybatis修改mysql变量_Java通过MyBatis框架对MySQL数据进行增删查改的基本方法
  5. 百练 1363.Rails
  6. excel统计行数_值得收藏的6个Excel函数公式(有讲解)
  7. 用命令导入导出MS SQL数据
  8. 苏宁易购:苏宁控股、苏宁电器合计质押约5.18亿股公司股份
  9. java将jfif格式转换成ipg_.jfif是什么格式 jfif格式怎么转jpg
  10. js 的 protype 小总结
  11. Form表单只提交field的值,而不进行页面跳转
  12. 终端如何查看虚拟环境_Python版本管理工具和虚拟环境
  13. 《Revisiting Self-Supervised Monocular Depth Estimation》论文笔记
  14. Mockplus 3.2前瞻,五大特色功能让你惊喜!
  15. [Python]第一章(建议收藏)
  16. 金山卫士界面源码解读及界面库分离(4)
  17. Name was not previously introduced as per JSP.5.3的解决办法
  18. html制作唐诗,Steve:HTML创始人来中国当教师 痴迷李白自称“唐诗”
  19. 当代中国最贵的汉字是什么?
  20. c语言使用双撇号为何不能运行,最简单的C程序设计——顺序程序设计

热门文章

  1. css不继承父类样式_提升你的Python编程能力,细说类的继承,拿走不谢
  2. 对比损失的PyTorch实现详解
  3. python 自动点击上传以后上传文件,python使用selenium模拟点击网页实现自动导入上传文件功能...
  4. python union函数_如何掌握Python union()方法及怎么用?
  5. java怎么表示正无穷大_java中怎样表示一个无穷大? 无穷小?
  6. android 保活方案_Android 后台保活手段总结 (上篇)
  7. 多个containers 共用一个pvc_2020阜新PVC-UH市政管厂家-烟台塑胶
  8. Mysql保存是事件驱动吗_【CHRIS RICHARDSON 微服务系列】事件驱动的数据管理-5
  9. python调用窗口找到文件,使用Python在Mac OS X中查找当前活动窗口
  10. C++11新特性之左值右值及移动语句与完美转发