benleggiero
08/15/2017, 1:07 PMshort
arithmetic.
when {
a == 0.toShort() || b == 0.toShort() || (a > 0) xor (b > 0) -> a+b
x > 0 -> if (Short.MAX_VALUE - a < b) Short.MAX_VALUE else a + b
else -> if (Short.MIN_VALUE - a < b) Short.MIN_VALUE else a + b
}.toShort()
Thread in Slack Conversation
also xor
is logically equivalent to !=