Re: Bits of a Word
- From: "Maarten Wiltink" <maarten@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 27 Aug 2008 15:15:06 +0200
"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
.
- References:
- Bits of a Word
- From: Amir
- Bits of a Word
- Prev by Date: Re: Tabs
- Next by Date: Re: Bits of a Word
- Previous by thread: Bits of a Word
- Next by thread: Re: Bits of a Word
- Index(es):