Sign in Join
Wiki copytemporary

Or/ru: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Or/ru

OldNewLine
1+# Логическая операция
2+
3+Логическая операция **Or** выдает значение [[True/ru|true]] в случае, если любой из операндов имеет значение true и [[False/ru|false]], если оба логических операнда равны false.
4+
5+## Таблица истинности
6+
7+| A | B | A or B |
8+|-----------|-----------|---------|
9+|   false   |   false   |   false |
10+|   false |   true |   true |
11+|   true |   false |   true |
12+|   true |   true |   true |
13+
14+# Побитовая операция
15+
16+Для логической операции **Or** (также известна, как Побитовое ИЛИ) требуются операнды порядкового типа и в результирующей переменной бит устанавливается в 1, если один из соответствующих битов в операндах равен 1, и в 0 если оба бита равны 0.
17+
18+## Установка бита
19+
20+``` pascal
21+function SetBit(const AValue, ABitNumber:integer):integer;
22+begin
23+ result := AValue or (1 shl ABitNumber);
24+end;
25+```
26+
27+Если вы вызовете SetBit(%1000,1), то получится %1010 (%1000 = 8 and %1010 = 10). Если вызовете SetBit(10,2), то получится 14 (14 = %1110). Если вызовете SetBit(10,1), то результатом будет 10.
28+
29+## См. также
30+
31+- [[And/ru|And]]
32+- [[Const/ru|Const]]
33+- [[Function/ru|Function]]
34+- [[Integer/ru|Integer]]
35+- [[Shl/ru|Shl]]
36+- [[Shr/ru|Shr]]
37+
38+---
39+*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](/wiki-contact).*

Back to history