clampNonNegative method

  1. @useResult
int clampNonNegative()

Returns this number rounded to the nearest int, with negatives clamped to 0.

Example:

3.6.clampNonNegative(); // 4
(-2).clampNonNegative(); // 0

Implementation

@useResult
int clampNonNegative() => this < 0 ? 0 : round();