Shl/fr
Deutsch · English · Français · Suomi · Русский
Généralité
Shl (Shift Left) décale à gauche une valeur binaire spécifié en premier opérande du nombre de bit spécifié en second opérande (contraire de shr).
P.ex.
L'instruction est : 00000100 shl 2 (décalage à gauche de 2 bits)
L'action est : 00000100 <- 00 (00 ajoute 2 00 à droite, les 00 de gauche "disparaissent")
Le résultat est : 00010000Autrement dit, cela revient à multiplier par la puissance de 2 équivalente (2^décalage = 4, dans notre exemple).
Effacer un bit
function ClearBit( const aValue, aBitNumber : integer ) : integer;
begin
result := aValue and not( 1 shl aBitNumber );
end;Si vous appelez ClearBit(%1111,1), vous obtenez %1101 (soit le nombre binaire 13).
Si vous appelez ClearBit(13,2), vous obtenez 9 (9 = %1001).
If you call ClearBit(13,2), then you get 9 (9 = %1001) .
See also
From the Free Pascal wiki, page "Shl/fr", as it stood on 2020-02-26 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.