Konuyu Oyla:
  • Derecelendirme: 5/5 - 2 oy
  • 1
  • 2
  • 3
  • 4
  • 5
Byte & Set Of
#11
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.
YouTube Delphi Tips
"Mantıklı adam kendini dünyaya uyarlar; mantıksız adam ise dünyayı kendine uydurmakta inat eder. Bu nedenle, tüm ilerleme o inatçı adama bağlıdır." - George Bernard Shaw
WWW
Cevapla


Bu Konudaki Yorumlar
Byte & Set Of - Yazar: Tuğrul HELVACI - 08-11-2017, Saat: 14:24
Byte & Set Of - Yazar: SimaWB - 08-11-2017, Saat: 15:17
Byte & Set Of - Yazar: Tuğrul HELVACI - 08-11-2017, Saat: 15:22
Byte & Set Of - Yazar: SimaWB - 08-11-2017, Saat: 15:47
Byte & Set Of - Yazar: Bahadir.Alkac - 08-11-2017, Saat: 16:05
Cvp: Byte & Set Of - Yazar: Tuğrul HELVACI - 08-11-2017, Saat: 16:18
Byte & Set Of - Yazar: SimaWB - 08-11-2017, Saat: 16:48
Byte & Set Of - Yazar: uparlayan - 08-11-2017, Saat: 16:49
Cvp: Byte & Set Of - Yazar: Tuğrul HELVACI - 08-11-2017, Saat: 16:56
Cvp: Byte & Set Of - Yazar: uparlayan - 08-11-2017, Saat: 17:18



Konuyu Okuyanlar: 1 Ziyaretçi