// Display the bits within a byte.
class ShowBits
{
  public static void main(String[] args)
  {
    int t;
    byte val;

	val = 4;
	System.out.println("value is: " + val);
	for(t=4; t > 0; t = t/2)
	{
	  if((val & t) != 0) System.out.print("1 ");
	  else System.out.print("0 ");
	  System.out.println("top loop iteration:  " + t);
    }

    val = 123;
    System.out.println("value is: " + val);
    for(t=128; t > 0; t = t/2)
    {
	  System.out.println("second loop iteration:  " + t);
      if((val & t) != 0) System.out.print("1 ");
      else System.out.print("0 ");
    }
  }
}
