private double doOperation(int beg, double lft, Operator opr, double rgt) {
    if(opr.unary!=RIGHT_SIDE && Double.isNaN(lft)) { throw exception(beg,"Mathematical NaN detected in right-operand"); }
    if(opr.unary!=LEFT_SIDE  && Double.isNaN(rgt)) { throw exception(beg,"Mathematical NaN detected in left-operand" ); }

    try { return opr.handler.evaluateOperator(lft,opr.symbol,rgt); }
    catch(ArithmeticException thr) {
        throw exception(beg,"Mathematical expression \""+expression+"\" failed to evaluate",thr);
        }
    catch(UnsupportedOperationException thr) {
        int tmp=beg;
        while(tmp>0 && getOperator(expression.charAt(tmp))==null) { tmp--; }                        // set up for offset of the offending operator
        throw exception(tmp,"Operator \""+opr.symbol+"\" not handled by math engine (Programmer error: The list of operators is inconsistent within the engine)");
        }
    }