The bitwise NOT : Bitwise NOT : Data Type C# Examples


C# Examples » Data Type » Bitwise NOT »

 

The bitwise NOT









    
using  System;  

class  Example  {  
    public  static  void  Main()  {  
        sbyte  b  =  -34;  
  
        for(int  t=128;  t  >  0;  t  =  t/2)  {  
            if((b  &  t)  !=  0)  
                    Console.Write("1  ");    
            if((b  &  t)  ==  0)  
                    Console.Write("0  ");    
        }  
        Console.WriteLine();  
  
        //  reverse  all  bits  
        b  =  (sbyte)  ~b;  
  
        for(int  t=128;  t  >  0;  t  =  t/2)  {  
            if((b  &  t)  !=  0)  
                  Console.Write("1  ");    
            if((b  &  t)  ==  0)  
                  Console.Write("0  ");    
        }  
    }  
}
    
   
  
   



Output

1 1 0 1 1 1 1 0
0 0 1 0 0 0 0 1


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Bitwise NOT