Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace ConsoleTest
- {
- class ConsoleTest
- {
- static void Main()
- {
- int v = int.Parse(Console.ReadLine());
- byte p = byte.Parse(Console.ReadLine());
- Console.WriteLine(Convert.ToString(v, 2).PadLeft(8,'0'));
- bool hasValueOne = false;
- int shifted = v >> p;
- string final = shifted.ToString();
- if (final.Last() == '1')
- {
- hasValueOne = true;
- }
- Console.WriteLine("Bit at position " + p + @" has value ""1"": " + hasValueOne);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment