home *** CD-ROM | disk | FTP | other *** search
- (* ------------------------------------------------------ *)
- (* TBIT.PAS *)
- (* Testprogramm der Unit Bit *)
- (* ------------------------------------------------------ *)
-
- PROGRAM TBit;
-
- USES crt,Bit;
-
- VAR s : SHORTINT;
- b,LV : BYTE;
- i : INTEGER;
- w : WORD;
- Taste: CHAR;
- Input: STRING;
-
- BEGIN
- WriteLn('Automatische Typkonvertierung');
- WriteLn('Bit Short Byte Integer Word');
- FOR LV:=0 TO 21 DO BEGIN
- s:=SetBit(0,LV);
- b:=SetBit(0,LV);
- i:=SetBit(0,LV);
- w:=SetBit(0,LV);
- WriteLn(LV:2,s:6,b:5,i:10,w:10)
- END;
- Write('-> Taste drücken');
- Taste:=readkey;
- ClrScr;
- REPEAT
- REPEAT
- Write('Bitte geben Sie eine Zahl in ',
- 'Binärdarstellung ein: ');
- ReadLn(Input);
- w:=IntVal(Input,2,i);
- IF i>0 THEN WriteLn('Fehler bei Position ',i);
- UNTIL i=0;
- WriteLn('Hexdarstellung: ',IntStr(w,16,0));
- WriteLn('Hexdarstellung mit führenden Nullen: ',
- IntStr(w,16,4));
- WriteLn('7''ner-Darstellung: ',IntStr(w,7,0));
- WriteLn('Zeichendarstellung: ',IntStr(w,$FF,0));
- WriteLn('Bit 4 bis 7 haben den Wert: ',BitGrp(w,4,4),
- ' (',IntStr(BitGrp(w,4,4),2,4),')');
- WriteLn('Binäre mit führenden Nullen: ',
- Intstr(w,2,16));
- WriteLn('Um 4 Bits nach rechts rotiert: ',
- IntStr(RoR(w,16,4),2,16));
- WriteLn('Das selbe mit den letzten 5 Bits: ',
- IntStr(RoR(w,5,4),2,16));
- WriteLn('Das selbe nach links: ',
- IntStr(RoL(w,5,4),2,16));
- Write('Ende mit Esc, Weiter beliebige andere Taste');
- Taste:=readkey;
- WriteLn;
- UNTIL ord(Taste)=27
- END.
- (* ------------------------------------------------------ *)