Advertisement
enevlogiev

bit exchange

Apr 16th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. using System;
  2.  
  3. namespace BitExchange
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             uint input = uint.Parse(Console.ReadLine());
  10.  
  11.             uint bits345 = (input >> 3) & 7;
  12.             uint bits242526 = (input >> 24) & 7;
  13.  
  14.             input &= ~((uint)7 << 3);
  15.             input &= ~((uint)7 << 24);
  16.  
  17.  
  18.             // uint magicNumber = Convert.ToUInt32("111110001111111111111111000111", 2);
  19.             // trqs si naglasish nulichkite i tn, shtoto mai ne sa 32 ; )
  20.             // i mai ne sa kydeto trea
  21.  
  22.             input |= bits345 << 24;
  23.             input |= bits242526 << 3;
  24.  
  25.             Console.WriteLine(input);
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement