Shl/fr: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | ## Généralité | |
| 2 | 2 | ||
| 3 | 3 | **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]]). | |
| 4 | 4 | ||
| 5 | 5 | P.ex. | |
| 6 | 6 | ||
| 7 | - | ||
| 8 | - | ||
| 9 | - | ||
| 10 | - | ||
| 11 | - | ||
| 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 | + | ``` | |
| 12 | 14 | ||
| 13 | 15 | Autrement dit, cela revient à multiplier par la puissance de 2 équivalente (2^décalage = 4, dans notre exemple). | |
| 14 | 16 | ||
| 15 | 17 | ## Effacer un bit | |
| 16 | 18 | ||
| 17 | 19 | ``` pascal | |
| 18 | 20 | function ClearBit( const aValue, aBitNumber : integer ) : integer; | |
| 19 | 21 | begin | |
| 20 | 22 | result := aValue and not( 1 shl aBitNumber ); | |
| 21 | 23 | end; | |
| 22 | 24 | ``` | |
| 23 | 25 | ||
| 24 | 26 | Si vous appelez ClearBit(%1111,1), vous obtenez %1101 (soit le [[Binary numeral system/fr|nombre binaire]] 13). | |
| 25 | 27 | ||
| 26 | 28 | Si vous appelez ClearBit(13,2), vous obtenez 9 (9 = %1001). | |
| 27 | 29 | ||
| 28 | 30 | If you call ClearBit(13,2), then you get 9 (9 = %1001) . | |
| 29 | 31 | ||
| 30 | 32 | ## See also | |
| 31 | 33 | ||
| 32 | 34 | - [[And/fr|And]] | |
| 33 | 35 | - [[Not/fr|Not]] | |
| 34 | 36 | - [[Or/fr|Set a bit]] | |
| 35 | 37 | - [[Xor/fr|Toggle a bit]] | |
| 36 | 38 | - [[Shr/fr|Shr]] | |
| 37 | 39 | - [[Bit manipulation/fr|Manipulation de bits]] | |
| 38 | 40 | ||
| 39 | 41 | --- | |
| 40 | 42 | *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).* |
