Examples of BigRational


Examples of wyautl.util.BigRational

  }

  protected void translate(Constant.Decimal e, int freeSlot,
      ArrayList<Bytecode> bytecodes) {
    BigRational rat = new BigRational(e.value);
    BigInteger den = rat.denominator();
    BigInteger num = rat.numerator();
    if(rat.isInteger()) {
      // this
      if(num.bitLength() < 32) {
        bytecodes.add(new Bytecode.LoadConst(num.intValue()));
        JvmType.Function ftype = new JvmType.Function(WHILEYRAT,T_INT);
        bytecodes.add(new Bytecode.Invoke(WHILEYRAT, "valueOf", ftype,
View Full Code Here

Examples of wyautl.util.BigRational

    byte[] numerator = new byte[size];
    reader.read(numerator);
    size = reader.read_uv();
    byte[] denominator = new byte[size];
    reader.read(denominator);
    return new Automaton.Real(new BigRational(new BigInteger(numerator),
        new BigInteger(denominator)));
  }
View Full Code Here

Examples of wyautl.util.BigRational

      Automaton.Int i = (Automaton.Int) state;
      byte[] bytes = i.value.toByteArray();
      output.write_uv(bytes.length);
    } else if (state instanceof Automaton.Real) {
      Automaton.Real r = (Automaton.Real) state;
      BigRational br = r.value;

      byte[] numbytes = br.numerator().toByteArray();
      output.write_uv(numbytes.length);
      output.write(numbytes);

      byte[] denbytes = br.denominator().toByteArray();
      output.write_uv(denbytes.length);

    } else if (state instanceof Automaton.Strung) {
      Automaton.Strung str = (Automaton.Strung) state;
      try {
View Full Code Here

Examples of wyautl.util.BigRational

      sb.append((char) next());
      while ((lookahead = lookahead()) != -1
          && Character.isDigit((char) lookahead)) {
        sb.append((char) next());
      }
      BigRational val = new BigRational(sb.toString());

      if(negative) {
        val = val.negate();
      }

      return automaton.add(new Automaton.Real(val));

    } else {
      BigInteger val = new BigInteger(sb.toString());

      if(negative) {
        val = val.negate();
      }

      return automaton.add(new Automaton.Int(val));
    }
  }
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.