Sign in Join
Wiki copytemporary

And: what changed

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

OldNewLine
11The binary operator `and` performs a logical conjunction. [[FPC]] also does a bitwise `and` when supplied with ordinal types.
22
33## Boolean operation
44
55The 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`.
66
77| `A` | `B` | `A and B` |
88|---------|---------|-----------|
99| `false` | `false` | `false` |
1010| `false` | `true` | `false` |
1111| `true` | `false` | `false` |
1212| `true` | `true` | `true` |
1313
1414## Bitwise operation
1515
1616FPC also defines a bitwise `and`. Taking two ordinal operands logical `and` is calculated bit by bit:
1717
18-`    1010'1100`\
19-`and 0011'0100`\
20-`――――――――――――`\
21-`    0010'0100`
18+```
19+ 1010'1100
20+and 0011'0100
21+――――――――――――
22+ 0010'0100
23+```
2224
2325## comparative remarks
2426
2527Depending 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`.
2628
2729## see also
2830
2931- [[Or|or]]
3032
3133---
3234*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).*

Back to history