Package lipstone.joshua.parser.types

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


    if (set.size() <= 0)
      return BigDec.ZERO;
    BigDec total = BigDec.ZERO;
    for (BigDec d : set)
      total = total.add(d);
    return total.divide(new BigDec(set.size()));
  }
 
  /**
   * @return the median of this set NOTE: this does not sort the set prior to getting the median
   */
 
View Full Code Here


              output = num1.pow(num2);
            }
            else if (operator == '*')
              output = num1.multiply(num2);
            else if (operator == '/')
              output = num1.divide(num2);
            else if (operator == '+')
              output = num1.add(num2);
            else if (operator == '-')
              output = num1.subtract(num2);
            else
View Full Code Here

      highestCo = BigDec.ONE;
      if (!lowestCo.isInt())
        return roots;
    }
    if (!lowestCo.isInt()) {
      highestCo = highestCo.divide(lowestCo);
      lowestCo = BigDec.ONE;
      if (!highestCo.isInt())
        return roots;
    }
   
View Full Code Here

    numerator = numerator.getFirstConsCell();
    denominator = denominator.getFirstConsCell();
    BigDec num = new BigDec(parser.run(numerator.length() > 0 ? numerator.remove() : new ConsCell(BigDec.ONE, ConsType.NUMBER)).toString());
    BigDec den = new BigDec(parser.run(denominator.length() > 0 ? denominator.remove() : new ConsCell(BigDec.ONE, ConsType.NUMBER)).toString()), gcd = num.gcd(den);
    num = num.divide(gcd);
    den = den.divide(gcd);
    ConsCell output = new ConsCell(num, ConsType.NUMBER, new ConsCell('/', ConsType.OPERATOR, new ConsCell(den, ConsType.NUMBER))).getLastConsCell();
    for (ConsCell key : orders) {
      ConsCell exp = orders.get(key);
      if (exp.length() == 1 && exp.getCarType() == ConsType.NUMBER) { //If the exponent is a real number
        if (((BigDec) exp.getCar()).eq(BigDec.ZERO))
View Full Code Here

        eqn = eqn.getFirstConsCell();
        if (parser.containsVariables(eqn, vars))
          continue;
        eqn = parser.run(eqn);
        if (eqn.length() == 1 && eqn.getCarType() == ConsType.NUMBER)
          coefficient = divide ? coefficient.divide((BigDec) eqn.getCar()) : coefficient.multiply((BigDec) eqn.getCar());
      }
    } while (!(current = current.getNextConsCell()).isNull());
    return negative ? coefficient.multiply(BigDec.MINUSONE) : coefficient;
  }
 
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.