Sign in Join
Wiki copytemporary

Not: what changed

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

OldNewLine
11The unary [[Operator|operator]] `not` negates a Boolean value. [[FPC]] also knows the bitwise `not` when supplied with an ordinal type.
22
33`not` is a [[Reserved word|reserved word]].
44
55## Boolean operation
66
77The 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.
88
99| `A` | `not A` |
1010|---------|---------|
1111| `false` | `true` |
1212| `true` | `false` |
1313
1414`not` has the highest precedence among logical operators.
1515
1616## Bitwise operation
1717
1818The bitwise `not` flips every bit in an ordinal type.
1919
20-`not 1100'1010`\
21-`―――――――――――――`\
22-`    0011'0101`
20+```text
21+not 1100'1010
22+―――――――――――――
23+ 0011'0101
24+```
2325
2426It 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`$.
2527
2628Note, 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`.
2729
2830- [`system.logicalNot`](https://www.freepascal.org/docs-html/rtl/system/.op-logicalnot-variant-ariant.html)
2931
3032---
3133*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).*
3234Category: Operators

Back to history