getbit.pp 335 B

12345678910111213141516171819202122
  1. program getbit;
  2. {$mode delphi}
  3. type
  4. plint = class
  5. digits: array of byte;
  6. end;
  7. function LGetBit(A: PLInt; Bit: Cardinal): Integer;
  8. begin
  9. Result := (A.Digits[(Bit - 1) shr 5 + 1] shr ((Bit - 1) and $1F{(Bit - 1) mod 32})) and 1;
  10. end;
  11. var
  12. p: plint;
  13. begin
  14. p:=plint.create;
  15. setlength(p.digits,10);
  16. lgetbit(p,4);
  17. end.