Not: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Not
| Old | New | Line | |
|---|---|---|---|
| 1 | + | The unary [[Operator|operator]] `not` negates a Boolean value. [[FPC]] also knows the bitwise `not` when supplied with an ordinal type. | |
| 2 | + | ||
| 3 | + | `not` is a [[Reserved word|reserved word]]. | |
| 4 | + | ||
| 5 | + | ## Boolean operation | |
| 6 | + | ||
| 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 | + | ||
| 9 | + | | `A` | `not A` | | |
| 10 | + | |---------|---------| | |
| 11 | + | | `false` | `true` | | |
| 12 | + | | `true` | `false` | | |
| 13 | + | ||
| 14 | + | `not` has the highest precedence among logical operators. | |
| 15 | + | ||
| 16 | + | ## Bitwise operation | |
| 17 | + | ||
| 18 | + | The bitwise `not` flips every bit in an ordinal type. | |
| 19 | + | ||
| 20 | + | `not 1100'1010`\ | |
| 21 | + | `―――――――――――――`\ | |
| 22 | + | ` 0011'0101` | |
| 23 | + | ||
| 24 | + | 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 | + | ||
| 26 | + | 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 | + | ||
| 28 | + | - [`system.logicalNot`](https://www.freepascal.org/docs-html/rtl/system/.op-logicalnot-variant-ariant.html) | |
| 29 | + | ||
| 30 | + | --- | |
| 31 | + | *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 | + | Category: Operators |
