Re: Bits of a Word



"Amir" <eghtedari.amir@xxxxxxxxx> wrote in message
news:1d0ae241-c447-41ab-8e78-1e43f5d040fd@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

I have a variable of type Word, I want to check the state of its bits
separately.
What ways exist for doing that.

The AND operator.

OR

The SHR operator and the Odd function.

function IsBitSet(const Value: DWord; const Index: 0..31): Boolean;
begin
Result:=Odd(Value shr Index);
end;

function IsBitSet(const Value: DWord; const Index: 0..31): Boolean;
begin
Result:=LongBool(Value and (1 shl Index));
end;

Groetjes,
Maarten Wiltink


.