multipleOf method

bool multipleOf(
  1. num input,
  2. num divisor
)

Returns true if input is a multiple of divisor.

A divisor of zero is treated as a schema-error guard: the spec requires multipleOf values to be strictly greater than zero, so a zero divisor returns false rather than throwing.

Implementation

bool multipleOf(num input, num divisor) {
  if (divisor == 0) return false;
  // Compute the quotient and check that its fractional part is negligibly
  // small, guarding against IEEE-754 rounding in decimal arithmetic.
  final quotient = input / divisor;
  return (quotient - quotient.roundToDouble()).abs() < _epsilon;
}