If not, it seems to be useful to have an operator (let's call it number) that would evaluate to the numerical value of its operand, but to zero if the operand was not numeric, or undefined. So that I could write something like number elem #key piececount, which would give me the expected 0 if #key was not a valid key in the piececount table.
The int operator, which already exists, should do what you want. It uses the PHP function intval to convert its input to an integer, and for input that is not numeric, it will return 0.
The int operator, which already exists, should do what you want. It uses the PHP function intval to convert its input to an integer, and for input that is not numeric, it will return 0.