Code: I'm doing a saturating `short` arithmetic.
`...

# announcementsb

benleggiero

08/15/2017, 1:07 PMCode: I'm doing a saturating

`short`

arithmetic.
Copy code

```
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()
```

1 reply
also `xor`

is logically equivalent to `!=`