RatNumeral constructor

RatNumeral(
  1. Rat value
)

Implementation

factory RatNumeral(Rat value) {
  if (value.n.isValidInt && value.d.isValidInt) {
    final ast = _mathContext._z3.mk_real_int64(
      value.n.toInt(),
      value.d.toInt(),
    );
    return _mathContext._getAST(ast) as RatNumeral;
  }
  final valuePtr = '$value'.toNativeUtf8();
  try {
    final ast = _mathContext._z3.mk_numeral(
      valuePtr.cast(),
      _mathContext._realSort,
    );
    return _mathContext._getAST(ast) as RatNumeral;
  } finally {
    malloc.free(valuePtr);
  }
}