home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / spezial / 13 / bit / bitsdemo.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-04-18  |  1.5 KB  |  50 lines

  1. (* ------------------------------------------------------ *)
  2. (*                 BITSDEMO.PAS                           *)
  3. PROGRAM bitsdemo;
  4.  
  5. uses crt, bits;
  6.  
  7. VAR i, j : INTEGER;
  8.     Str1 : STRING[16];
  9. BEGIN
  10.  
  11.   ClrScr;
  12.   Write  ('Bitte geben Sie eine Zahl ein       : ');
  13.   ReadLn (i);
  14.   Write  ('Bitte geben Sie die Bitposition ein : ');
  15.   ReadLn (j);
  16.   WriteLn;
  17.   Str1 := IntStr(i);
  18.   WriteLn ('Die Zahl lautet in der ',
  19.            'Binaerdarstellung        : ',Str1);
  20.   WriteLn ('und wieder zurueck ',
  21.            'konvertiert                  : ',IntVal (Str1));
  22.   Write  ('Bit ',j,' ist');
  23.   IF ITstBit (i,j) THEN BEGIN
  24.     WriteLn (' gesetzt.');
  25.     Str1 := IntStr(IClrBit(i,j));
  26.     WriteLn ('Die Zahl lautet mit geloeschtem Bit',
  27.              '             : ',Str1); END
  28.   ELSE BEGIN
  29.     WriteLn (' nicht gesetzt.');
  30.     Str1 := IntStr(ISetBit(i,j));
  31.     WriteLn ('Die Zahl lautet mit gesetztem Bit',
  32.              '               : ',Str1)
  33.   END;
  34.   WriteLn ('Um eine Stelle nach links geshiftet  ',
  35.            'lautet sie : ',IntStr(i SHL 1));
  36.   WriteLn ('Um eine Stelle nach links ',
  37.            ' rotiert   lautet sie : ',IntStr(IROL(i,1)));
  38.   Str1 := IntStr(i SHR 1);
  39.   WriteLn ('Um eine Stelle nach rechts geshiftet ',
  40.            'lautet sie : ',Str1);
  41.   Str1 := IntStr(IROR(i,1));
  42.   WriteLn ('Um eine Stelle nach rechts  rotiert ',
  43.            ' lautet sie : ',Str1)
  44. END.
  45. (* ------------------------------------------------------ *)
  46. (*                Ende von BITSDEMO.PAS                   *)
  47.  
  48.  
  49.  
  50.