在Java的BigInteger中向右移动
要在BigInteger中向右移动,请使用shiftRight()
方法。
java.math.BigInteger.shiftRight(intn)返回一个BigInteger,其值为(this>>n)。进行符号扩展。移位距离n可以为负,在这种情况下,此方法执行左移。它计算地板(this/2n)。
以下是一个例子-
示例
import java.math.*; public class Demo { public static void main(String[] args) { BigInteger one; one = new BigInteger("25"); one = one.shiftRight(3); System.out.println("Result: " +one); } }
输出结果
Result: 3