checkedSum

fun checkedSum(a: Int, b: Int): Int

Return the sum of two integers, checking for overflow

Return

a+b

Parameters

a

an Int operand

b

an Int operand

fun checkedSum(add: Sequence<Int>, sub: Sequence<Int>): Int

Add and subtract non-negative integers, checking for overflow

Compute add* - sub*, ensuring an exception is thrown iff the final result overflows (and not because of an intermediate overflowing result).

Return

add* - sub*

Parameters

add

a Sequence of non-negative integers to add

sub

a Sequence of non-negative integers to subtract