Display the bits within a byte : Operator bitwise : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Operator bitwise »

 

Display the bits within a byte









    

/*
C#: The Complete Reference 
by Herbert Schildt 

Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/
// Display the bits within a byte.  
using System; 
 
public class ShowBits { 
  public static void Main() { 
    int t; 
    byte val;  
  
    val = 123; 
    for(t=128; t > 0; t = t/2) { 
      if((val & t) != 0) Console.Write("1 ");  
      if((val & t) == 0) Console.Write("0 ");  
    } 
  } 
}


           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Operator bitwise