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

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

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

  • shiftLeft() method is used to shift the given number of bits towards the left side in this BigInteger.

    shiftLeft()方法用于将给定数量的位向此BigInteger中的左侧移动。

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

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

  • shiftLeft() method may throw an exception at the time of shifting bits.

    shiftLeft()方法在移位位时可能会引发异常。

    ArithmeticException: This exception may throw when the given parameter value holds Integer.MIN_VALUE.

    ArithmeticException :当给定参数值包含Integer.MIN_VALUE时,可能引发此异常。

Syntax:

句法:

    public BigInteger shiftLeft(int number);

Parameter(s):

参数:

  • int number – represents the value in bits and when it holds negative value it performs right shift instead of left.

    int number –表示以位为单位的值,当它保持负值时,它执行右移而不是左移。

Return value:

返回值:

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

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

Example:

例:

// Java program to demonstrate the example
// of BigInteger setBit(int pos) method of BigInteger
import java.math.*;
public class SetBitOfBI {public static void main(String args[]) {// Initialize a variable str
String str = "10";
// Initialize a BigInteger object
BigInteger b_int = new BigInteger(str);
// Display b_int
System.out.println("b_int: " + b_int);
// Display Binary representation of  str
System.out.println("Binary Representation of 10: 1010 ");
System.out.println();
// Here, this method setBit(int) method is used
// to set the  bit value from "0" to 1" at the
// given indices in this BigInteger
// b_int and the binary representation of b_int
// is 1010 so the bit "1" is set at the given
// indices (0) so the new binary representation
// is 1011 i.e. 11
BigInteger set_bit = b_int.setBit(0);
System.out.println("b_int.setBit(0): " + set_bit);
System.out.println("Binary Representation of 11: 1011 ");
}
}

Output

输出量

b_int: 10
Binary Representation of 10: 1010 b_int.setBit(0): 11
Binary Representation of 11: 1011

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

Java BigInteger类| 带示例的shiftLeft()方法相关推荐

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

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

  2. Java BigInteger类| 带实例的splitAndRemainder()方法

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

  3. Java LocalDate类| 带示例的getDayOfYear()方法

    LocalDate类的getDayOfYear()方法 (LocalDate Class getDayOfYear() method) getDayOfYear() method is availab ...

  4. Java LocalDateTime类| 带示例的getDayOfWeek()方法

    LocalDateTime类getDayOfWeek()方法 (LocalDateTime Class getDayOfWeek() method) getDayOfWeek() method is ...

  5. Java LocalDate类| 带示例的format()方法

    LocalDate类format()方法 (LocalDate Class format() method) format() method is available in java.time pac ...

  6. Java Duration类| 带示例的compareTo()方法

    持续时间类compareTo()方法 (Duration Class compareTo() method) compareTo() method is available in java.time ...

  7. Java LocalDate类| 带示例的compareTo()方法

    LocalDate类compareTo()方法 (LocalDate Class compareTo() method) compareTo() method is available in java ...

  8. Java LocalDateTime类| 带示例的getMinute()方法

    LocalDateTime类getMinute()方法 (LocalDateTime Class getMinute() method) getMinute() method is available ...

  9. Java LocalDate类| 带示例的getEra()方法

    LocalDate类的getEra()方法 (LocalDate Class getEra() method) getEra() method is available in java.time pa ...

最新文章

  1. 这几个 Python 的小技巧,你会么?
  2. 《信息安全技术健康医疗数据安全指南》国家标准
  3. 万亿级日志与行为数据存储查询技术剖析——Hbase系预聚合方案、Dremel系parquet列存储、预聚合系、Lucene系...
  4. mysql数据库技术方案,MySql数据库优化方案
  5. css深入理解之overflow
  6. SQL Server 2008 正式版安装指南(附序列号)
  7. [BUUCTF-pwn]——jarvisoj_level1
  8. SAP UI5 DatePicker setDateValue(tempString)
  9. 补码、无符号数减法运算
  10. 如何快速搭建云原生企业级数据湖架构及实践分享
  11. mysql查询最小的id_Mysql查询表中最小可用id值的方法
  12. (6)vue.js基础语法—插值表达式
  13. 计算机等级考试绝对应用,96年4月至210年全国计算机等级考试绝对全收集.docx
  14. VUE中使用Echarts图表
  15. 怎么使用et代理换ip软件切换电脑手机的上网ip_使用教程
  16. 报税反写服务器返回为空,【原创】报税后反写是怎么回事?
  17. matlab行星运动轨迹仿真动画,Matlab动画模拟太阳系行星运动
  18. 一致性检验评价方法kappa
  19. java模拟器环境_Win10 + Appium+夜神/MuMu模拟器环境搭建
  20. 邮箱功能开发总结(以新浪邮箱为例子)

热门文章

  1. vulhub安装教程
  2. 5.jQueryAjax
  3. 前端路由实现原理(history)
  4. python学习 day6 (3月7日)
  5. BZOJ1004 [HNOI2008]Cards 【burnside定理 + 01背包】
  6. html适配Anroid手机
  7. KMP算法的java实现
  8. jquery实现导航栏鼠标点击后实行背景高亮,点击离开恢复(超级简单!!!!)...
  9. 【机器学习】EM最大期望算法
  10. android ImageView 之 android:scaleTye=