Kotlin: Integers to ByteArray

Yuta SHIMAKAWA
1 min readMay 24, 2019

--

Though code sample above is written with Int, the same way would be applicative to other integer types, such as Long.

In Kotlin 1.3, Unsigned integer types, such as UInt , was introduced as experimental feature. In such case, the code is much simpler, because we do not have to considerate negative values.

--

--