Sign in Join
Wiki copytemporary

Or/fr

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

Opération booléenne

Le oubooléen produit une valeur true si l'une au moins de ses opérandes est vraie. Il produit false uniquement si les deux opérandes sont fausses.

Table de vérité

A B A or B
  false     false     false
  false   true   true
  true   false   true
  true   true   true

Opération bit à bit

Le Or logique (aussi connu comme or bit à bit) demande des opérandes ordinales, met à 1 un bit de résultat si l'un des deux bits correspondants dans les opérandes vaut 1 et met à 0 si les deux bits sont à 0. Cela pour tous les bits des opérandes.

Mettre un bit à 1

pascal
function SetBit(const AValue, ABitNumber:integer):integer;
begin
   result := AValue or (1 shl ABitNumber);
end;

Si vous appelez SetBit(%1000,1), vous obtenez alors %1010 (%1000 = 8 et %1010 = 10). Si vous appelez SetBit(10,2), vous obtenez 14 (14 = %1110). Si vous appelez SetBit(10,1), vous obtenez 10.

Voir aussi


From the Free Pascal wiki, page "Or/fr", as it stood on 2020-02-23 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 1, last changed by WikiArchive .

Talk about this page

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