Hi. How do I typecast `Byte` to `Int`. `FF` should...
# announcements
t
Hi. How do I typecast
Byte
to
Int
.
FF
should result to value 255
p
.toInt()
t
toInt() converts
FF
to
-1
j
x.toInt() and 0xFF
Conversion to a larger integer performs sign extension. The
and
removes the extended sign
t
Thanks 🙂
k
If you use this often you can write an extension funtion for it:
Byte.toPositiveInt() = this.toInt() and 0xFF
.