If the user wants to push -10 onto the stack.

Would I do "10 OP_NEGATE" ?

Or could I convert it to the hex value by doing 0x80 + 10 = 0X8A ?

1 Answer 1


Both will work. OP_NEGATE simply XORs with 0x80, so you can also directly push the result.

  • And we take the absolute value of a signed integer right? In this case 10 could be written with one byte so I think that using two bytes was overkill? May 6, 2018 at 9:30
  • Not necessarily. Some operations, like hashing, will produce different results for positive or negative numbers. Some operations, like signatures, will fail if the R value is negative. It depends on what you're doing. May 6, 2018 at 14:08
  • 1
    Take into account that for numbers between -1 and 16 inclusive, short 1-byte opcodes exist. Pushing any other number (like -10) requires an explicit push operation of the bytes encoding of the number. Both "10 NEGATE" and "-10" are therefore 2-byte scripts. May 6, 2018 at 23:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.