Package lipstone.joshua.parser.types

Examples of lipstone.joshua.parser.types.BigDec.subtract()


    }
   
    while ((operation.equals("sec") || operation.equals("csc") || operation.equals("cot")) && inp.lt(BigDec.ZERO))
      inp = inp.add(new BigDec(Math.PI * 2));
    while ((operation.equals("sec") || operation.equals("csc") || operation.equals("cot")) && inp.gt(new BigDec(Math.PI * 2)))
      inp = inp.subtract(new BigDec(Math.PI * 2));
   
    if (operation.equals("sin"))
      output = new BigDec(ApcomplexMath.sin(inp.getInternal()));
    if (operation.equals("cos"))
      output = new BigDec(ApcomplexMath.cos(inp.getInternal()));
View Full Code Here


    ConsCell num = parser.run(parts.get(0));
    if (num.getCarType() != ConsType.NUMBER || !((BigDec) num.getCar()).isInt() || !((BigDec) num.getCar()).gteq(BigDec.ZERO))
      throw new ParserException("The factorial operation is only defined for arguments that evaluate to whole numbers", this);
    BigDec cap = (BigDec) num.getCar();
    if (cap.gteq(numFactorial))
      for (BigDec i = new BigDec(cap); i.gteq(BigDec.ONE); i = i.subtract(numFactorial))
        output = output.multiply(i);
    return output;
  }
 
  /**
 
View Full Code Here

            else if (operator == '/')
              output = num1.divide(num2);
            else if (operator == '+')
              output = num1.add(num2);
            else if (operator == '-')
              output = num1.subtract(num2);
            else
              throw new UndefinedResultException(lastPlugin);
            current.replaceCar(new ConsCell(output, ConsType.NUMBER));
            forward = false;
          }
View Full Code Here

        }
        //if (power.getCarType() != ConsType.NUMBER)
        //throw new ParserException("Unsupported exponential format in the equation solver", null);
        BigDec pow = new BigDec(power.toString());
        int exp = pow.intValue();
        pow = pow.subtract(new BigDec(exp));
        boolean negative = exp < 0;
        for (int i = 0; i < exp; i++)
          insert = insert.append(new ConsCell(negative ? '/' : '*', ConsType.OPERATOR)).append(base.clone());
        if (!pow.eq(BigDec.ZERO))
          insert = insert.append(new ConsCell(negative ? '/' : '*', ConsType.OPERATOR)).append(base.clone()).append(new ConsCell('^', ConsType.OPERATOR)).append(new ConsCell(pow, ConsType.NUMBER));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.