BigRational constructor
Constructs a BigRational instance from the given numerator and optional denominator.
Implementation
factory BigRational(BigInt numerator, [BigInt? denominator]) {
if (denominator == null) {
return BigRational._(numerator, _one);
}
if (denominator == _zero) {
throw ArgumentException("Denominator cannot be 0.");
}
if (numerator == _zero) {
return BigRational._(_zero, _one);
}
return _reduce(numerator, denominator);
}