Get, Clear, Set and Enable bit operations for pascal.
1
2 function GetBit(const Value: DWord; const Bit: Byte): Boolean;
3 begin
4 Result := (Value and (1 shl Bit)) <> 0;
5 end;
6
7 function ClearBit(const Value: DWord; const Bit: Byte): DWord;
8 begin
9 Result := Value and not (1 shl Bit);
10 end;
11
12 function SetBit(const Value: DWord; const Bit: Byte): DWord;
13 begin
14 Result := Value or (1 shl Bit);
15 end;
16
17 function EnableBit(const Value: DWord; const Bit: Byte; const TurnOn: Boolean): DWord;
18 begin
19 Result := (Value or (1 shl Bit)) xor (Integer(not TurnOn) shl Bit);
20 end;