Jump to content

[Delphi] Detect value of specific bit

- - - - -

  • Please log in to reply
No replies to this topic

#1
LuthfiHakim

LuthfiHakim

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 763 posts
The following code will see the value of specific bit (specified by AIndex) of an integer value. If the bit is 1, the function returns True, else it returns False.


function IsBitSet(const AValue, AIndex: Integer): Boolean;

begin

  Result := AValue and (1 shl AIndex) <> 0;

end;






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users