OP_NOT - Boolean Inversion
From TeachMeBitcoin, the free encyclopedia
Reading time: 1 min
5. OP_NOT — Boolean Inversion
Opcode Reference
Opcode: OP_NOT
Hex: 0x91
Decimal: 145
Input: a
Output: !a (1 if a == 0, else 0)
Overview
OP_NOT performs a boolean NOT operation. It does not perform bitwise negation — instead it treats the top stack element as a boolean and inverts it. If the top element is 0 (or the empty byte array), OP_NOT pushes 1. For any non-zero value, it pushes 0.
Truth Table
``` Input | Output
☕ Help support TeachMeBitcoin
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation:
Ethereum:
0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin:
bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana:
4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J