Java BigInteger setBit() MethodThe setBit() method of Java BigInteger class is used to set the bit position. This method returns a BigInteger whose value is equivalent to this BigInteger with the designated bit set. Syntax:Parameter:n- Index of the bit to set entered by the user. Returns:This method returns ( this | (1<<n)). Exception:ArithmeticException - n is negative. Example 1Test it NowOutput: SetBit operation on 5 at index 1 gives 7 Example 2Test it NowOutput: java.lang.ArithmeticException: Negative bit address Example 3Test it NowOutput: SetBit operation on 5 at index 2 gives 5 Next TopicJava BigInteger |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India