/* C# code snippet to display the bits within a byte using bitwise '&' */
using System;
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 ");
    }
  }
}
Friday, September 5, 2008
C# program to display the bits within a byte!
Posted by Nanya at 6:46 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment