clampNonNegative method
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();
Returns this number rounded to the nearest int, with negatives clamped to 0.
Example:
3.6.clampNonNegative(); // 4
(-2).clampNonNegative(); // 0
@useResult
int clampNonNegative() => this < 0 ? 0 : round();