Sign in Join
Wiki copytemporary

Shl/fr: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## Généralité
22
33**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/fr|shr]]).
44
55P.ex.
66
7-`L'instruction est : 00000100 shl 2 (décalage à gauche de 2 bits)`\
8-` `\
9-`L'action est :  00000100 <- 00 (00 ajoute 2 00 à droite, les 00 de gauche "disparaissent")`\
10-` `\
11-`Le résultat est :  00010000`
7+```text
8+L'instruction est : 00000100 shl 2 (décalage à gauche de 2 bits)
9+
10+L'action est : 00000100 <- 00 (00 ajoute 2 00 à droite, les 00 de gauche "disparaissent")
11+
12+Le résultat est : 00010000
13+```
1214
1315Autrement dit, cela revient à multiplier par la puissance de 2 équivalente (2^décalage = 4, dans notre exemple).
1416
1517## Effacer un bit
1618
1719``` pascal
1820function ClearBit( const aValue, aBitNumber : integer ) : integer;
1921begin
2022 result := aValue and not( 1 shl aBitNumber );
2123end;
2224```
2325
2426Si vous appelez ClearBit(%1111,1), vous obtenez %1101 (soit le [[Binary numeral system/fr|nombre binaire]] 13).
2527
2628Si vous appelez ClearBit(13,2), vous obtenez 9 (9 = %1001).
2729
2830If you call ClearBit(13,2), then you get 9 (9 = %1001) .
2931
3032## See also
3133
3234- [[And/fr|And]]
3335- [[Not/fr|Not]]
3436- [[Or/fr|Set a bit]]
3537- [[Xor/fr|Toggle a bit]]
3638- [[Shr/fr|Shr]]
3739- [[Bit manipulation/fr|Manipulation de bits]]
3840
3941---
4042*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](/wiki-contact).*

Back to history