-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgf_Bits.pas
35 lines (25 loc) · 860 Bytes
/
gf_Bits.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
unit gf_Bits;
{$I gf_base.inc}
interface
function IsBitSet(const val: longint; const TheBit: byte): boolean;
function BitOn(const val: longint; const TheBit: byte): LongInt;
function BitOff(const val: longint; const TheBit: byte): LongInt;
function BitToggle(const val: longint; const TheBit: byte): LongInt;
implementation
function IsBitSet(const val: longint; const TheBit: byte): boolean;
begin
result := (val and (1 shl TheBit)) <> 0;
end;
function BitOn(const val: longint; const TheBit: byte): LongInt;
begin
result := val or (1 shl TheBit);
end;
function BitOff(const val: longint; const TheBit: byte): LongInt;
begin
result := val and ((1 shl TheBit) xor $FFFFFFFF);
end;
function BitToggle(const val: longint; const TheBit: byte): LongInt;
begin
result := val xor (1 shl TheBit);
end;
end.