Not: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | The unary [[Operator|operator]] `not` negates a Boolean value. [[FPC]] also knows the bitwise `not` when supplied with an ordinal type. | |
| 2 | 2 | ||
| 3 | 3 | `not` is a [[Reserved word|reserved word]]. | |
| 4 | 4 | ||
| 5 | 5 | ## Boolean operation | |
| 6 | 6 | ||
| 7 | 7 | The operator `not` represents the logical negation $`\neg A`$. In electrical engineering one might write $`-A`$ or $`\overline{A}`$ instead, however the unary [[Minus|minus sign]] has a different meaning in programming. | |
| 8 | 8 | ||
| 9 | 9 | | `A` | `not A` | | |
| 10 | 10 | |---------|---------| | |
| 11 | 11 | | `false` | `true` | | |
| 12 | 12 | | `true` | `false` | | |
| 13 | 13 | ||
| 14 | 14 | `not` has the highest precedence among logical operators. | |
| 15 | 15 | ||
| 16 | 16 | ## Bitwise operation | |
| 17 | 17 | ||
| 18 | 18 | The bitwise `not` flips every bit in an ordinal type. | |
| 19 | 19 | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 20 | + | ```text | |
| 21 | + | not 1100'1010 | |
| 22 | + | ――――――――――――― | |
| 23 | + | 0011'0101 | |
| 24 | + | ``` | |
| 23 | 25 | ||
| 24 | 26 | It effectively calculates the one’s complement. On virtually all platforms it is implemented by the `not` instruction. On NAND-gate-based architectures the `not` instruction can be calculated by the expression $`A ⌅ A`$. | |
| 25 | 27 | ||
| 26 | 28 | Note, that only `not %0` will *definitely* result in a value interpretable as `true`. However, not every other `not x` will result in a value interpretable as `false`, since only `0` is considered as `false` and every other value as `true`. For example, `boolean(not %1)` will evaluate as `true`, but only `boolean(not high(nativeUInt))` will evaluate to `false`. | |
| 27 | 29 | ||
| 28 | 30 | - [`system.logicalNot`](https://www.freepascal.org/docs-html/rtl/system/.op-logicalnot-variant-ariant.html) | |
| 29 | 31 | ||
| 30 | 32 | --- | |
| 31 | 33 | *From the Free Pascal wiki, page "Not", as it stood on 2020-10-16 after a change by Rfc1394, 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).* | |
| 32 | 34 | Category: Operators |
