func (*InclusiveRange) closestInRange(value, start, end, step int) int {
	// Possibly clamp the value if it is outside the range
	if end >= start {
		if value < start {
			return start
		} else if value > end {
			return end
		}

	} else {
		if value > start {
			return start
		} else if value < end {
			return end
		}
	}

	// No calculation needed if there is no stepping
	if step == 1 || step == -1 {
		return value
	}

	// Modified the value so that it is a properly stepped
	// increment within the range
	return (((value - start) / step) * step) + start
}
func (*InclusiveRange) closestInRange(value, start, end, step int) int {
	
	if end >= start {
		if value < start {
			return start
		} else if value > end {
			return end
		}

	} else {
		if value > start {
			return start
		} else if value < end {
			return end
		}
	}

	
	if step == 1 || step == -1 {
		return value
	}

	
	
	return (((value - start) / step) * step) + start
}
func ( * InclusiveRange ) closestInRange ( value , start , end , step int ) int { // Possibly clamp the value if it is outside the range if end >= start { if value < start { return start } else if value > end { return end } } else { if value > start { return start } else if value < end { return end } } // No calculation needed if there is no stepping if step == 1 || step == - 1 { return value } // Modified the value so that it is a properly stepped // increment within the range return ( ( ( value - start ) / step ) * step ) + start }
// closestInRange finds the closest valid value within the range,
// to a given value. Values outside the range are clipped to either
// the range min or max.
closestInRange finds the closest valid value within the range to a given value . Values outside the range are clipped to either the range min or max .