procedure SetBit(var Value: QWord; Index: Byte);begin Value := Value or (QWord(State) shl Index);end
TInt32Bits = bitpacked record Bit0, Bit1, Bit2, Bit3, Bit4, Bit5, Bit6, Bit7,...,Bit31: 0..1;end;PInt32Bits = TInt32Bits^;...var i: Integer; pi: PInt32Bits;begin i := 0; pi := @i; pi.Bit1 := 1; pi.Bit25 := 1;end;
I needed something to help me use the Tag property of a component as bit set, so the code examples in http://wiki.lazarus.freepascal.org/Bit_manipulation are enough for the time beingJust a warning: The SetBit procedure is wrong, 'State' is not included in the parameters.
Quote from: vfclists on August 01, 2014, 10:26:49 amI needed something to help me use the Tag property of a component as bit set, so the code examples in http://wiki.lazarus.freepascal.org/Bit_manipulation are enough for the time beingJust a warning: The SetBit procedure is wrong, 'State' is not included in the parameters.Why not correct the wiki page? It's what it's there for.