coming from C/C++, I am shocked I can't find easy ...
# getting-started
a
coming from C/C++, I am shocked I can't find easy ways to do low-level stuff, like casting between signed and unsigned values while keeping the internal bit representation of a value ¯\_(ツ)_/¯
j
Take a look at UInt
Copy code
val signedInt: Int = -123456
val unsignedInt: UInt = signedInt.toUInt()
You can use and, or, xor, and shl/shr for shifts
Copy code
val a: UInt = 0xFFFFFFFEu
val b: Int = -10
val result = a and b.toUInt()