Example #1
0
void TheoryArith::printRational(ExprStream& os, const Rational& r,
                                bool printAsReal)
{
  // Print rational
  if (r.isInteger()) {
    if (r < 0) {
      if (os.lang() == SPASS_LANG) {
        os << "-" << (-r).toString();
        if (printAsReal) os << ".0";
      } else {
        os << "(" << push;
        if (os.lang() == SMTLIB_LANG) {
          os << "~";
        }
        else {
          os << "-";
        }
        os << space << (-r).toString();
        if (printAsReal) os << ".0";
        os << push << ")";
      }
    }
    else {
      os << r.toString();
      if (printAsReal) os << ".0";
    }
  }
  else {
    os << "(" << push << "/ ";
    Rational tmp = r.getNumerator();
    if (tmp < 0) {
      if (os.lang() == SPASS_LANG) {
        os << "-" << (-tmp).toString();
        if (printAsReal) os << ".0";
      } else {
        os << "(" << push;
        if (os.lang() == SMTLIB_LANG) {
          os << "~";
        }
        else {
          os << "-";
        }
        os << space << (-tmp).toString();
        if (printAsReal) os << ".0";
        os << push << ")";
      }
    }
    else {
      os << tmp.toString();
      if (printAsReal) os << ".0";
    }
    os << space;
    tmp = r.getDenominator();
    DebugAssert(tmp > 0 && tmp.isInteger(), "Unexpected rational denominator");
    os << tmp.toString();
    if (printAsReal) os << ".0";
    os << push << ")";
  }
}
Example #2
0
  static void checkInt(const Rational& n, const string& funName) {
    DebugAssert(n.isInteger(),
		("CVC3::Rational::" + funName
		 + ": argument is not an integer: " + n.toString()).c_str());
  }