home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / 1988 / 12 / tricks / tbit.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1988-09-26  |  1.8 KB  |  59 lines

  1. (* ------------------------------------------------------ *)
  2. (*                   TBIT.PAS                             *)
  3. (*           Testprogramm der Unit Bit                    *)
  4. (* ------------------------------------------------------ *)
  5.  
  6. PROGRAM TBit;
  7.  
  8. USES crt,Bit;
  9.  
  10. VAR s    : SHORTINT;
  11.     b,LV : BYTE;
  12.     i    : INTEGER;
  13.     w    : WORD;
  14.     Taste: CHAR;
  15.     Input: STRING;
  16.  
  17. BEGIN
  18.   WriteLn('Automatische Typkonvertierung');
  19.   WriteLn('Bit Short Byte   Integer      Word');
  20.   FOR LV:=0 TO 21 DO BEGIN
  21.     s:=SetBit(0,LV);
  22.     b:=SetBit(0,LV);
  23.     i:=SetBit(0,LV);
  24.     w:=SetBit(0,LV);
  25.     WriteLn(LV:2,s:6,b:5,i:10,w:10)
  26.   END;
  27.   Write('-> Taste drücken');
  28.   Taste:=readkey;
  29.   ClrScr;
  30.   REPEAT
  31.     REPEAT
  32.       Write('Bitte geben Sie eine Zahl in ',
  33.             'Binärdarstellung ein: ');
  34.       ReadLn(Input);
  35.       w:=IntVal(Input,2,i);
  36.       IF i>0 THEN WriteLn('Fehler bei Position ',i);
  37.     UNTIL i=0;
  38.     WriteLn('Hexdarstellung: ',IntStr(w,16,0));
  39.     WriteLn('Hexdarstellung mit führenden Nullen: ',
  40.              IntStr(w,16,4));
  41.     WriteLn('7''ner-Darstellung: ',IntStr(w,7,0));
  42.     WriteLn('Zeichendarstellung: ',IntStr(w,$FF,0));
  43.     WriteLn('Bit 4 bis 7 haben den Wert: ',BitGrp(w,4,4),
  44.              ' (',IntStr(BitGrp(w,4,4),2,4),')');
  45.     WriteLn('Binäre mit führenden Nullen:      ',
  46.              Intstr(w,2,16));
  47.     WriteLn('Um 4 Bits nach rechts rotiert:    ',
  48.              IntStr(RoR(w,16,4),2,16));
  49.     WriteLn('Das selbe mit den letzten 5 Bits: ',
  50.              IntStr(RoR(w,5,4),2,16));
  51.     WriteLn('Das selbe nach links:             ',
  52.              IntStr(RoL(w,5,4),2,16));
  53.     Write('Ende mit Esc, Weiter beliebige andere Taste');
  54.     Taste:=readkey;
  55.     WriteLn;
  56.   UNTIL ord(Taste)=27
  57. END.
  58. (* ------------------------------------------------------ *)
  59.