According to the wiki page, OP_IFDUP will duplicate the top of the stack "if the input is true or false". It seems to me that everything is true or false when interpreted as a boolean.

According to the source code:

case OP_IFDUP:
    valtype vch = stacktop(-1);
    if (CastToBool(vch))

That suggests the wiki is incorrect. What would be a better way of wording it, and what is the operation for?


It duplicates the top stack item if the top stack item is not 0 and not negative 0. I'm not sure where this would be useful.

  • Thanks. I fixed the wiki accordingly. I copied the description from the OP_IF operation, since the code is the same. – Chris Moore Mar 19 '12 at 21:46

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.