Autor Beitrag
Szorcc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Do 27.03.03 08:44 
Hi,

wie kann man einen Word-Wert (Bsp. integer) in einen Binary-Wert (Bsp. 00110110) umwandeln, einzelne Bits ändern und wieder zurück wandeln?

Gruß Szorcc
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Do 27.03.03 09:25 
Möchtest du die Bit-Werte ausgeben? Wenn nein, dann musst du gar nichts konvertieren, da der Prozessor sowieso nur mit Binärzahlen arbeiten kann.

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
function BitClear(Value: Integer; Bit: Integer): Integer;
begin
  Result := Value and not (1 shl Bit);
end;

function BitSet(Value: Integer; Bit: Integer): Integer;
begin
  Result := Value or (1 shl Bit);
end;

function BitToggle(Value: Integer; Bit: Integer): Integer;
begin
  Result := Value xor (1 shl Bit);
end;

_________________
Ist Zeit wirklich Geld?