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

  1. /*--------------------------------------*/
  2. /*                    */
  3. /*              ADDBIT(X)        */
  4. /*                    */
  5. /* Functionality:            */
  6. /*     Marks the first off bit of an     */
  7. /*     integer which is on when    */
  8. /*     scanning from right to left.    */
  9. /* Arguments:                */
  10. /*     0: The integer to scan.        */
  11. /* Functions used:            */
  12. /*    POWER()                */
  13. /* Returns: Nothing            */
  14. /* Author: John Callicotte        */
  15. /* Date created/modified: 09/01/88    */
  16. /*                    */
  17. /*--------------------------------------*/
  18.  
  19. void addbit(b)
  20. int b[];
  21. {
  22.     int d,j;
  23.     if (b[0]==32767)    /* No bits to turn on, so we leave */
  24.             goto END;
  25.     for (j=0;j<16;j++){
  26.              d=power(2,j);
  27.              if (b[0]<d){
  28.                  b[0]+=d;
  29.                  j=16;
  30.              }
  31.     }
  32.  
  33. END:    ;
  34. }