⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 poweroperatortoken.java

📁 JAVA 数学程序库 提供常规的数值计算程序包
💻 JAVA
字号:
package jmathlib.core.tokens;

import jmathlib.core.interpreter.*;

/**Class representing all power operators used in an expression*/
public class PowerOperatorToken extends BinaryOperatorToken
{

    /**Constructor taking the operator and priority
    @param _operator = the actual operator being created */
    public PowerOperatorToken (char _operator)
    {
    	/**call the super constructor, type defaults to ttoperator and operands to 2*/
        super(_operator, POWER_PRIORITY);
    }

    /**evaluates the operator
    @param operands = the operators operands
    @return the result as an OperandToken*/
    public OperandToken evaluate(Token[] operands)
    {
        OperandToken result = null;

        OperandToken left = ((OperandToken)operands[0]); 
        
        if(left == null)
            Errors.throwMathLibException("PowerOperatorToken left null");
        	
        OperandToken right = ((OperandToken)operands[1]);
        if(right == null)
            Errors.throwMathLibException("PowerOperatorToken right null");

        //now evaluate op on left and right        
        if(value == 'm')
        {
            result = left.mPower(right);
        }
        else if (value=='p')
        {
            // e.g. 1.^[1,2,3]  or [1,2,3].^4
            result = left.power(right);
        }
        else
            Errors.throwMathLibException("PowerOperatorToken unknown power");


        return result;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -