Venciity

[Java] Third Bit

May 2nd, 2014
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.30 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class ThirdBit {
  5.  
  6.     public static void main(String[] args)
  7.     {
  8.         int position = 3;
  9.         Scanner input = new Scanner(System.in);
  10.         int n = input.nextInt();
  11.         int nRightPosition = n >> position;
  12.         int bit = nRightPosition & 1;
  13.         System.out.println(bit);
  14.     }
  15.  
  16. }
Advertisement
Add Comment
Please, Sign In to add comment