My loop in c#
for (int cnt = 0; cnt <16; cnt ++, newMask >>= 1, oldMask >>=1)
{
if ((newMask & 1) == (oldMask & 1))
{
continue;
}
int status = (newMask & 1);
int bitMask = 1 << cnt;
// more code...
}
Same loop, translated in kotlin:
var cnt = 0
while (cnt < 16) {
if (newMask and 1 === oldMask and 1) {
cnt++
newMask = newMask shr 1
oldMask = oldMask shr 1
continue
}
val status = newMask and 1
val bitMask = 1 shl cnt
// more code...
cnt++
newMask = newMask shr 1
oldMask = oldMask shr 1
}
The Kotlin version seems less readable and more prone to errors.