Sign in Join
Wiki copytemporary

Or/ru

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

Логическая операция

Логическая операция Or выдает значение true в случае, если любой из операндов имеет значение true и false, если оба логических операнда равны false.

Таблица истинности

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

Побитовая операция

Для логической операции Or (также известна, как Побитовое ИЛИ) требуются операнды порядкового типа и в результирующей переменной бит устанавливается в 1, если один из соответствующих битов в операндах равен 1, и в 0 если оба бита равны 0.

Установка бита

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

Если вы вызовете SetBit(%1000,1), то получится %1010 (%1000 = 8 and %1010 = 10). Если вызовете SetBit(10,2), то получится 14 (14 = %1110). Если вызовете SetBit(10,1), то результатом будет 10.

См. также


From the Free Pascal wiki, page "Or/ru", 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.