mayap

GetBitAtPositionP

Apr 11th, 2014
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.43 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ExtractingBits
  8. {
  9.     class ExtractingBits
  10.     {
  11.         static void Main()
  12.         {
  13.             uint num = uint.Parse(Console.ReadLine());
  14.             int p = 3;
  15.             uint numRightP = num >> p;
  16.             uint bit = numRightP & 1;
  17.             Console.WriteLine(bit);
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment