I found that ISZERO is an opcode but I can't find what is the purpose of ISZERO.

Can somebody please guide me what is the purpose of ISZERO?


2 Answers 2


Although this is an old question here's what I found on debugging further. As @haxerl explains above it looks like the only purpose of ISZERO is to check if the top of stack is zero. How does it do it? It does a simple not operation on the last number as seen in the screenshots below from remix

Before After

  • Hi, please tell me what you mean by the last number from the screenshot? Zulfi.
    – zak100
    Feb 5 at 18:41

According to ethereum yellow paper, it is like a simple not operation in any other programming language. You can search for the use of not operation on many case but they mostly use so that you dont have to check for many condition: https://stackoverflow.com/questions/4775379/using-not-operator-in-if-conditions.

  • What is the meaning of following paragraph in the context of ISZERO & mishandled exception "Detecting a mishandled exception is straightforward. Recall that if a callee yields an exception, it pushes 0 to the caller's operand stack. Thus we only need to check if the contract executes the ISZERO instruction (which checks if the top value of the stack is 0) after every call. If it does not, any exception occurred in the callee is ignored. Thus, we flag such contract as a contract that mishandles exceptions." Some body please guide me.
    – zak100
    Jun 1, 2019 at 4:28
  • @zak100 i think that is another question. You should make a new thread to ask
    – haxerl
    Jun 1, 2019 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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