Not/fr: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | - | ||
| 2 | - | ||
| 3 | - | ||
| 4 | 1 | ## Opération booléenne | |
| 5 | 2 | ||
| 6 | 3 | **Not** produit une valeur [[True/fr|true]] si la valeur de l'opérande est [[False/fr|false]] et inversement. | |
| 7 | 4 | ||
| 8 | 5 | ### Table de vérité | |
| 9 | 6 | ||
| 10 | 7 | | A | Not A | | |
| 11 | 8 | |-----------|-----------| | |
| 12 | 9 | | false | true | | |
| 13 | 10 | | true | false | | |
| 14 | 11 | ||
| 15 | 12 | ## Opération bit à bit | |
| 16 | 13 | ||
| 17 | 14 | **not** bit à bit inverse les bits (1 devient 0, 0 devient 1). | |
| 18 | 15 | ||
| 19 | 16 | ### Complément à 1 | |
| 20 | 17 | ||
| 21 | 18 | ``` pascal | |
| 22 | 19 | function OnesComplement ( const aValue : byte ): byte; | |
| 23 | 20 | begin | |
| 24 | 21 | result := Not AValue; | |
| 25 | 22 | end; | |
| 26 | 23 | ``` | |
| 27 | 24 | ||
| 28 | 25 | Si vous appelez OnesComplement([[Percent sign/fr|%]]10000000), vous obtenez alors %01111111 (%10000000 = 128 et %01111111 = 127). Si vous appelez OnesComplement(%00000111), vous obtenez 248 (248 = %11111000). | |
| 29 | 26 | ||
| 30 | 27 | ``` pascal | |
| 31 | 28 | function OnesComplement2 ( const aValue : shortint ): shortint; | |
| 32 | 29 | begin | |
| 33 | 30 | result := Not AValue; | |
| 34 | 31 | end; | |
| 35 | 32 | ``` | |
| 36 | 33 | ||
| 37 | 34 | If you call OnesComplement2(%00000010) then get %11111101 (%00000010 = 2 and %11111101 = -3 when [[Type|type]] is shortint). If you call OnesComplement2(7) then get -8 (-8 = %11111000 when type is shortint and 7 = %00000111 ). | |
| 38 | 35 | ||
| 39 | 36 | ## See also | |
| 40 | 37 | ||
| 41 | 38 | - [[And/fr|And]] | |
| 42 | 39 | - [[Or/fr|Or]] | |
| 43 | 40 | - [[Shl/fr|Shl]] | |
| 44 | 41 | - [[Const/fr|Const]] | |
| 45 | 42 | - [[Function/fr|Function]] | |
| 46 | 43 | - [[Byte/fr|Byte]] | |
| 47 | 44 | - [[Shortint/fr|Shortint]] | |
| 48 | 45 | - [[Shl/fr|#Clear_a_bit| Clear_a_bit]] (exemple d'opération bit à bit) | |
| 49 | 46 | - [[Bit manipulation/fr|Bit manipulation]] | |
| 50 | 47 | ||
| 51 | 48 | --- | |
| 52 | 49 | *From the Free Pascal wiki, page "Not/fr", as it stood on 2020-02-21 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).* |
