home *** CD-ROM | disk | FTP | other *** search
- (* ------------------------------------------------------ *)
- (* BITSDEMO.PAS *)
- PROGRAM bitsdemo;
-
- uses crt, bits;
-
- VAR i, j : INTEGER;
- Str1 : STRING[16];
- BEGIN
-
- ClrScr;
- Write ('Bitte geben Sie eine Zahl ein : ');
- ReadLn (i);
- Write ('Bitte geben Sie die Bitposition ein : ');
- ReadLn (j);
- WriteLn;
- Str1 := IntStr(i);
- WriteLn ('Die Zahl lautet in der ',
- 'Binaerdarstellung : ',Str1);
- WriteLn ('und wieder zurueck ',
- 'konvertiert : ',IntVal (Str1));
- Write ('Bit ',j,' ist');
- IF ITstBit (i,j) THEN BEGIN
- WriteLn (' gesetzt.');
- Str1 := IntStr(IClrBit(i,j));
- WriteLn ('Die Zahl lautet mit geloeschtem Bit',
- ' : ',Str1); END
- ELSE BEGIN
- WriteLn (' nicht gesetzt.');
- Str1 := IntStr(ISetBit(i,j));
- WriteLn ('Die Zahl lautet mit gesetztem Bit',
- ' : ',Str1)
- END;
- WriteLn ('Um eine Stelle nach links geshiftet ',
- 'lautet sie : ',IntStr(i SHL 1));
- WriteLn ('Um eine Stelle nach links ',
- ' rotiert lautet sie : ',IntStr(IROL(i,1)));
- Str1 := IntStr(i SHR 1);
- WriteLn ('Um eine Stelle nach rechts geshiftet ',
- 'lautet sie : ',Str1);
- Str1 := IntStr(IROR(i,1));
- WriteLn ('Um eine Stelle nach rechts rotiert ',
- ' lautet sie : ',Str1)
- END.
- (* ------------------------------------------------------ *)
- (* Ende von BITSDEMO.PAS *)
-
-
-
-