home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 1 / FishNMoreVol1.bin / more / code_examples / librar / showbits.c < prev    next >
Text File  |  1989-02-08  |  640b  |  27 lines

  1. /*--------------------------------------*/
  2. /*                    */
  3. /*             SHOWBITS(X,X)        */
  4. /*                    */
  5. /* Displays the bit representation of    */
  6. /* the integer given in the first argu- */
  7. /* ment in the character array given in    */
  8. /* the second argument.            */
  9. /*                    */
  10. /*--------------------------------------*/
  11. void showbits(a,c)
  12. int a;
  13. char c[8];
  14. {
  15.     int j,d,e;
  16.     d=a;
  17.     for (j=0;j<8;j++){
  18.              e=power(2,7-j);
  19.              if (d>=e){
  20.                  c[j]=49;
  21.                  d-=e;
  22.              }
  23.              else
  24.                  c[j]=48;
  25.     }
  26. }    
  27.