Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Enter whole number : ");
- var v = int.Parse(Console.ReadLine());
- Console.Write("Enter possition of the bit : ");
- var p = int.Parse(Console.ReadLine());
- var result = ((v >> p) % 2 == 1);
- Console.WriteLine("The {0}-th bit = 1: {1}" , p, result);
- // lines for check
- //Console.WriteLine("FEDCBA9876543210");
- //Console.WriteLine(Convert.ToString(v , 2).PadLeft(16, '0'));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement