Int
has the same MAX_VALUE
and MIN_VALUE
properties as java.lang.Integer
but doesn’t appear to have a SIZE
equivalent (the number of bits). I’m doing my bit arithmetic with Int
’s but referencing java.lang.Integer.SIZE
, which looks a bit wacky but it was that or code it as 32.
java.lang.Integer
has a lot of good stuff in there. I’ve been making use of methods like numberOfTrailingZeros()
, rotateRight()
and bitCount()
. There’s some heavy-duty science in those functions, which matters for low-latency applications. The last of those, bitCount()
, making use of the Hamming Weight / SWAR algorithm or possibly the popcount
x86 machine instruction if available. If would be great to have this hard-core science added to the scalar integer types in Kotlin.