Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace _10.BitPosition
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Number: ");
- int v = int.Parse(Console.ReadLine());
- Console.Write("Position of the bit: ");
- int p = int.Parse(Console.ReadLine());
- int mask = 1 << p;
- //Console.WriteLine("The {0} bit in {1} is {2}", p, v, (v&mask) != 0 ? 1 : 0);
- Console.WriteLine((v&mask) != 0 ? true : false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment