opcodeNot treats the top item on the data stack as an integer and replaces it with its "inverted" value (0 becomes 1, non-zero becomes 0). NOTE: While it would probably make more sense to treat the top item as a boolean, and push the opposite, which is really what the intention of this opcode is, i
(op *opcode, data []byte, vm *Engine)
| 1495 | // Stack transformation (x2!=0): [... x1 1] -> [... x1 0] |
| 1496 | // Stack transformation (x2!=0): [... x1 17] -> [... x1 0] |
| 1497 | func opcodeNot(op *opcode, data []byte, vm *Engine) error { |
| 1498 | m, err := vm.dstack.PopInt() |
| 1499 | if err != nil { |
| 1500 | return err |
| 1501 | } |
| 1502 | |
| 1503 | if m == 0 { |
| 1504 | vm.dstack.PushInt(scriptNum(1)) |
| 1505 | } else { |
| 1506 | vm.dstack.PushInt(scriptNum(0)) |
| 1507 | } |
| 1508 | return nil |
| 1509 | } |
| 1510 | |
| 1511 | // opcode0NotEqual treats the top item on the data stack as an integer and |
| 1512 | // replaces it with either a 0 if it is zero, or a 1 if it is not zero. |