Difference between revisions of "Shl"
From Free Pascal wiki
Jump to navigationJump to searchJwdietrich (talk | contribs) (Categorization) |
(Use wiki standard heading level: start with level 2. Added links to see also) |
||
Line 2: | Line 2: | ||
<br> | <br> | ||
<br> | <br> | ||
+ | == Overview == | ||
'''Sh'''ift '''l'''eft ('''shl''') performs a left bit-shift operation (opposite than [[Shr|shr]]). | '''Sh'''ift '''l'''eft ('''shl''') performs a left bit-shift operation (opposite than [[Shr|shr]]). | ||
Line 20: | Line 21: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | If you call ClearBit(%1111,1) then get %1101 (%1111 = 15 and %1101 = 13). | + | If you call ClearBit(%1111,1), then you get %1101 (%1111 = 15 and %1101 = 13). |
− | |||
− | |||
+ | If you call ClearBit(13,2), then you get 9 (9 = %1001) . | ||
+ | == See also == | ||
+ | * [[And]] | ||
+ | * [[Not]] | ||
* [[Or# Set a bit|Set a bit]] | * [[Or# Set a bit|Set a bit]] | ||
* [[Xor# Toggle a bit|Toggle a bit]] | * [[Xor# Toggle a bit|Toggle a bit]] | ||
+ | * [[Bit manipulation]] | ||
[[Category:Pascal]] | [[Category:Pascal]] |
Revision as of 14:26, 5 May 2014
Overview
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
Clear a bit
function ClearBit( const aValue, aBitNumber : integer ) : integer;
begin
result := aValue and not( 1 shl aBitNumber );
end;
If you call ClearBit(%1111,1), then you get %1101 (%1111 = 15 and %1101 = 13).
If you call ClearBit(13,2), then you get 9 (9 = %1001) .