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;
- using System.Threading.Tasks;
- namespace BitWiseOperatorsTest
- {
- class Program
- {
- static void Main(string[] args)
- {
- byte a = 3; //00000011 = 3
- // ~a = 11111100
- byte b = 5; //00000101 = 5
- Console.WriteLine(a | b); //00000111 = 7
- Console.WriteLine(a & b); //00000001 = 1
- // true ^ true = false
- // false ^ false = false
- // true ^ false = true
- // false ^ true = true
- Console.WriteLine(a ^ b); //00000110 = 6
- Console.WriteLine(~a & b); //00000100 = 4 ~ обръща битовете
- Console.WriteLine(a << 1); //00000110 = 6
- Console.WriteLine(a >> 1); //00000001 = 1
- Console.WriteLine(a >> 2); //00000000 = 0
- Console.WriteLine(a << 2); //00001100 = 12
- Console.WriteLine(~a); //11111100 = -4
- Console.WriteLine((byte)~a);//11111100 = -4 = 252
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment