Rational.fromMixed constructor
Creates a new Rational from wholePart
, numerator
,
and _denominator
.
Implementation
const Rational.fromMixed(
int wholePart, [
int numerator = 0,
this._denominator = 1,
]) : assert(numerator >= 0, 'The numerator cannot be negative.'),
assert(_denominator != 0, 'The denominator cannot be zero.'),
_numerator = ((wholePart < 0 ? -wholePart : wholePart) * _denominator +
numerator) *
(wholePart < 0 ? -1 : 1);