Rational.fromMixed constructor

const Rational.fromMixed(
  1. int wholePart, [
  2. int numerator = 0,
  3. int _denominator = 1
])

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);