Script: How to check if the top item on the main stack is numeric or not? I'm looking for the clearest way to check whether the top element of the stack is numeric or not.
Thank you in advance
The best way that I know is quite involved because bitcoin-core standardness rules around Minimal representation of script ints. If you really need to do this, I can add detail in an updated answer.
Execution vs Satisfaction:
But in almost all cases, you should never really need to check such a thing. Recall that Bitcoin Script satisfaction requires Script executes successfully. At the end of the day, we are not interested in what is execution result, we are interested in whether the witness is valid or not. And the user redeeming the coins knows whether the pushed number is ScriptInt or not, they are let the interpreter know via additional boolean input.
Previous Code: where stack top is element `e`
OP_ISTOPNUMERIC # hypothetical that pushes 1 or 0 onto the stack top
OP_IF 
    &lt;process_num&gt;
OP_ELSE
    &lt;something_else&gt;
OP_ENDIF

can be read written equivalently with two user input elements [e, e_is_num] where e_is_num is at stack top denoting whether e is numeric or not.
New code: with stack as `[e, e_is_num]`
OP_IF 
    &lt;process_num&gt;
OP_ELSE
    &lt;something_else&gt;
OP_ENDIF