Byte & Set Of - Baskı Önizleme +- Delphi Can (https://www.delphican.com) +-- Forum: Delphi (https://www.delphican.com/forumdisplay.php?fid=3) +--- Forum: Access violation (https://www.delphican.com/forumdisplay.php?fid=136) +--- Konu Başlığı: Byte & Set Of (/showthread.php?tid=1502) Sayfalar:
1
2
|
Cvp: Byte & Set Of - uparlayan - 08-11-2017 program Bitter; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils; type TByteSet = set of 0..7; function SetBit(Bitler: TByteSet): Byte; begin TByteSet(Result) := Bitler; end; function GetBit(aBayt: Byte): TByteSet; begin Result := TByteSet(aBayt); end; function BitToStr(aBayt: Byte): String; var I: Integer; begin Result := '0x'; { aslında bir if... } for I := 0 to 7 do Result := Result + Byte( I in GetBit(aBayt) ).ToString; end; var Veri: Byte; begin Veri := SetBit([1,3,5,7]); Writeln(Veri.ToString + ' - ' + BitToStr(Veri) ); Veri := SetBit([0,2,4,6]); Writeln(Veri.ToString + ' - ' + BitToStr(Veri) ); Veri := SetBit([1,2,3,4]); Writeln(Veri.ToString + ' - ' + BitToStr(Veri) ); readln; end. |