
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Shift right in a BigInteger in Java
To shift right in a BigInteger, use the shiftRight() method.
The java.math.BigInteger.shiftRight(int n) returns a BigInteger whose value is (this >> n). Sign extension is performed. The shift distance, n, may be negative, in which case this method performs a left shift. It computes floor(this / 2n).
The following is an example −
Example
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); } }
Output
Result: 3
- Related Questions & Answers
- Shift left in a BigInteger in Java
- Java Program to shift bits in a BigInteger
- Bitwise right shift operator in Java
- Left Shift and Right Shift Operators in C/C++
- Bitwise right shift operators in C#
- Negate a BigInteger in Java
- What does the bitwise right shift operator do in Java?
- Explain JavaScript Bitwise NOT, Left shift and Right shift?
- Bitwise Right/ left shift numbers in Arduino
- Java Program to shift array elements to the right
- Multiply one BigInteger to another BigInteger in Java
- Subtract one BigInteger from another BigInteger in Java
- Divide one BigInteger from another BigInteger in Java
- BigInteger class in Java
- Shift strings Circular left and right in JavaScript
Advertisements