floorToMultipleOf method

int floorToMultipleOf(
  1. int multipleOf
)

Rounds a non-negative integer down to nearest multiple of multipleOf that is less-than-or-equal-to this integer.

multipleOf must be positive.

Implementation

int floorToMultipleOf(int multipleOf) {
  assert(this >= 0);
  assert(multipleOf > 0);
  return (this ~/ multipleOf) * multipleOf;
}