<Why do arithmetic operations on bytes return an i...
# stackoverflow
u
Why do arithmetic operations on bytes return an int in kotlin? Consider this code: val x1: Byte = 0x00 val x2: Byte = 0x01 val x3: Byte = x1 + x2; This gives a compile error, because the result of adding 2 Bytes is an Int. To work around this, I need to manually cast the result back into a byte: val x3: Byte = (x1 + x2).toByte() This is very counter-intuative. Why do the arithmetic operators work like this?