Exemplo n.º 1
0
  public void evaluate(Environment aEnvironment, int aStackTop) throws Exception {
    BigNumber x = org.mathpiper.lisp.Utility.getNumber(aEnvironment, aStackTop, 1);

    Cons resultCons = x.dumpNumber(aEnvironment, aStackTop);

    /*
    ConsPointer isVerbosePointer = Utility.lispEvaluate(aEnvironment, aStackTop, "InVerboseMode();");

    if(((String)isVerbosePointer.car()).equals("True"))
    {
        x.dumpNumber(aEnvironment, aStackTop, aEnvironment.iCurrentOutput);
    }
    */

    getTopOfStackPointer(aEnvironment, aStackTop).setCons(resultCons);
  } // end method.
Exemplo n.º 2
0
  public void evaluate(Environment aEnvironment, int aStackTop) throws Exception {
    BigNumber x = org.mathpiper.lisp.Utility.getNumber(aEnvironment, aStackTop, 1);
    BigNumber y = org.mathpiper.lisp.Utility.getNumber(aEnvironment, aStackTop, 2);
    long result = 0; // initialize just in case

    if (x.isInteger() && x.isSmall() && y.isInteger() && y.isSmall()) {
      // bits_to_digits uses unsigned long, see numbers.h
      int base = (int) y.toDouble();
      result = Utility.digitsToBits((long) (x.toDouble()), base);
    } else {
      throw new EvaluationException(
          "BitsToDigits: error: arguments ("
              + x.toDouble()
              + ", "
              + y.toDouble()
              + ") must be small integers",
          aEnvironment.iCurrentInput.iStatus.getFileName(),
          aEnvironment.iCurrentInput.iStatus.getLineNumber(),
          aEnvironment.iCurrentInput.iStatus.getLineIndex());
    }
    BigNumber z = new BigNumber(aEnvironment.getPrecision());
    z.setTo((long) result);
    getTopOfStackPointer(aEnvironment, aStackTop)
        .setCons(new org.mathpiper.lisp.cons.NumberCons(z));
  }