Sign in Join
Wiki copytemporary

Not/fr

Deutsch · English · Français · Suomi · Русский

Opération booléenne

Not produit une valeur true si la valeur de l'opérande est false et inversement.

Table de vérité

A Not A
  false     true
  true     false  

Opération bit à bit

not bit à bit inverse les bits (1 devient 0, 0 devient 1).

Complément à 1

pascal
 function OnesComplement ( const aValue : byte ): byte;
 begin
   result := Not AValue;
 end;

Si vous appelez OnesComplement(%10000000), vous obtenez alors %01111111 (%10000000 = 128 et %01111111 = 127). Si vous appelez OnesComplement(%00000111), vous obtenez 248 (248 = %11111000).

pascal
 function OnesComplement2 ( const aValue : shortint ): shortint;
 begin
   result := Not AValue;
 end;

If you call OnesComplement2(%00000010) then get %11111101 (%00000010 = 2 and %11111101 = -3 when type is shortint). If you call OnesComplement2(7) then get -8 (-8 = %11111000 when type is shortint and 7 = %00000111 ).

See also


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.

Revision 2, last changed by Trev .

Edited on wiki.freepascal.org by 2 people, 2016–2020

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
E-ricCreated page
E-ric (minor)
TrevFixed syntax highlighting; removed categories included in template (minor)

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.