Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Jonas Raoni Soares Silva http://jsfromhell.com

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Simple bit operations //Pascal functions

Get, Clear, Set and Enable bit operations for pascal.

   1  
   2  function GetBit(const Value: DWord; const Bit: Byte): Boolean;
   3  begin
   4    Result := (Value and (1 shl Bit)) <> 0;
   5  end;
   6  
   7  function ClearBit(const Value: DWord; const Bit: Byte): DWord;
   8  begin
   9  	Result := Value and not (1 shl Bit);
  10  end;
  11  
  12  function SetBit(const Value: DWord; const Bit: Byte): DWord;
  13  begin
  14  	Result := Value or (1 shl Bit);
  15  end;
  16  
  17  function EnableBit(const Value: DWord; const Bit: Byte; const TurnOn: Boolean): DWord;
  18  begin
  19  	Result := (Value or (1 shl Bit)) xor (Integer(not TurnOn) shl Bit);
  20  end;
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS