midpoint

fun Int.midpoint(other: Int): Int

Returns the midpoint of this value and other without intermediate overflow.

Rounds toward this value for odd differences, matching (a + b) / 2 on in-range inputs while staying correct near Int.MAX_VALUE and Int.MIN_VALUE.


fun Long.midpoint(other: Long): Long

Returns the midpoint of this value and other without intermediate overflow.

Rounds toward this value for odd differences, matching (a + b) / 2 on in-range inputs while staying correct near Long.MAX_VALUE and Long.MIN_VALUE.