Shl

From Free Pascal wiki
Revision as of 06:56, 24 October 2007 by Djzepi (talk | contribs)
Jump to navigationJump to search

Shift left (shl) performs a left bit-shift operation (opposite than shr).

E.g

Command is:  00000100  shl 2
 
Action is:  00000100 <- 00
 
Result is:  00010000

Toggle a bit

<delphi> function ToggleBit(const AValue,ABitNumber:integer):integer; begin

  result := AValue xor 1 shl ABitNumber;

end; </delphi>

If you call ToggleBit(11,0) then get 10. If you call ToggleBit(10,2) then get 14.

Read more