Shr/fr
Deutsch · English · Français · Русский
Généralités
Shr (Shift right) décale à droite une valeur binaire spécifié en premier opérande du nombre de bit spécifié en second opérande (contraire de shl).
Shr avec les types signés
Note: contrairement à l'opérateur >> en langage C, l'opérateur shr est un décalage de bit logique (non arithmétique), même si l'opérande de gauche est un entier signé. Une conversion de type implicite et un extension vers un type non signé plus large peut être réalisée avant l'opération de décalage. Vérifiez ce que le programme suivant imprime réellement.
program ShrTest;
begin
WriteLn(ShortInt(-3) shr 1);
end.Le bit est-il mis ?
function isBitSet(AValue, ABitNumber:integer):boolean;
begin
result:=odd(AValue shr ABitNumber);
end;Voir aussi
From the Free Pascal wiki, page "Shr/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.