operator % method

PgDecimal operator %(
  1. PgDecimal other
)

Resto da divisão truncada, com o sinal do dividendo (% do PostgreSQL). A escala é a maior dos operandos.

Implementation

PgDecimal operator %(PgDecimal other) {
  if (_kind == _nan || other._kind == _nan) return nan;
  if (_kind != _finite) return nan;
  if (other._kind != _finite) return this;
  if (other._unscaled == BigInt.zero) {
    throw UnsupportedError('Division by zero');
  }
  final scale = _scale > other._scale ? _scale : other._scale;
  final a = _upscale(_unscaled, _scale, scale);
  final b = _upscale(other._unscaled, other._scale, scale);
  return PgDecimal._finiteValue(a.remainder(b), scale);
}