If you use trunk fpc, then just include
sysutils and
syshelpers and you can do something like:
...
var
MyDword: dword;
begin
MyDword := %111000111000111000111;
MyDword.Words[0] := 77;
MyDword.Bits[9] := true;
MyDword.Nibbles[0] := $A;
WriteLn('MyDword.ToBinString = ', MyDword.ToBinString);
WriteLn('MyDword.HighestSetBitPos = ' + MyDword.HighestSetBitPos.ToString);
WriteLn('MyDword.SetBitsCount = ' + MyDword.SetBitsCount.ToString);
WriteLn('MyDword.ToHexString = ', MyDword.ToHexString);
...
Full example can be found in \fpcsrc\packages\rtl-objpas\examples\syshelpersdemo.pas.
If you are not using trunk, then just install
bithelpers package from my signature (you can find it in OPM as well), and you will be able to do the same.