And: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: And
| Old | New | Line | |
|---|---|---|---|
| 1 | + | The binary operator `and` performs a logical conjunction. [[FPC]] also does a bitwise `and` when supplied with ordinal types. | |
| 2 | + | ||
| 3 | + | ## Boolean operation | |
| 4 | + | ||
| 5 | + | The operator `and` accepts to two Boolean type values. It is the logical conjunction written in classic logic as $`A \land B`$. Electrical engineers may write $`A \times B`$ or $`A \cdot B`$, or eliminating the multiplication sign altogether writing $`AB`$. However, the [[*|asterisk]] has a different meaning in programming. The Boolean `and` evaluates to [[false and true|true]] if and only if both operands are `true`. | |
| 6 | + | ||
| 7 | + | | `A` | `B` | `A and B` | | |
| 8 | + | |---------|---------|-----------| | |
| 9 | + | | `false` | `false` | `false` | | |
| 10 | + | | `false` | `true` | `false` | | |
| 11 | + | | `true` | `false` | `false` | | |
| 12 | + | | `true` | `true` | `true` | | |
| 13 | + | ||
| 14 | + | ## Bitwise operation | |
| 15 | + | ||
| 16 | + | FPC also defines a bitwise `and`. Taking two ordinal operands logical `and` is calculated bit by bit: | |
| 17 | + | ||
| 18 | + | ` 1010'1100`\ | |
| 19 | + | `and 0011'0100`\ | |
| 20 | + | `――――――――――――`\ | |
| 21 | + | ` 0010'0100` | |
| 22 | + | ||
| 23 | + | ## comparative remarks | |
| 24 | + | ||
| 25 | + | Depending on the compiler's specific implementation of the data type [[Set|set]], the [[Asterisk|intersection of sets]] virtually does the same as the bitwise `and`. | |
| 26 | + | ||
| 27 | + | ## see also | |
| 28 | + | ||
| 29 | + | - [[Or|or]] | |
| 30 | + | ||
| 31 | + | --- | |
| 32 | + | *From the Free Pascal wiki, page "And", as it stood on 2022-11-27 after a change by Kai Burghardt, 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).* |
