Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ExtractBitFromInteger
- {
- class ExtractBitFromInteger
- {
- static void Main()
- {
- Console.Write("Enter the number : ");
- int number = int.Parse(Console.ReadLine());
- Console.Write("Enter the bit : ");
- int bit = int.Parse(Console.ReadLine());
- int move = number >> bit;
- int result = move & 1;
- Console.WriteLine("The bit on position {0} is {1}" , bit , result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement