Edoardo Luppi
05/20/2025, 11:10 AMUint8Array.get/set use Short as element type is correct in kotlin-wrappers.
You end up in situations where you need to return the Short element from a Byte function, which means what you'd naively do is get(index).toByte(), however that changes the representation of the underlying value.
toByte(bytes[_unary__edvuaz]) & 255;
I think the appropriate type for U* typed arrays is still Byte, as effectively it's 8 bits, not 16 bits.turansky
05/20/2025, 11:12 AMEdoardo Luppi
05/20/2025, 11:12 AMturansky
05/20/2025, 11:13 AMEdoardo Luppi
05/20/2025, 11:13 AMturansky
05/20/2025, 11:14 AMturansky
05/20/2025, 11:14 AMEdoardo Luppi
05/20/2025, 11:14 AMshort means on the JVM, which is not what we want.Edoardo Luppi
05/20/2025, 11:53 AM0xFF.unsafeCast<Byte>(). If you try to do the same on a standard Uint8Array, you can simply use 0xFF.toByte().turansky
05/20/2025, 11:59 AMturansky
05/20/2025, 12:00 PMEdoardo Luppi
05/20/2025, 12:00 PMturansky
05/20/2025, 12:01 PMturansky
05/20/2025, 12:03 PMEdoardo Luppi
05/20/2025, 12:09 PMturansky
05/20/2025, 6:10 PMUint8Array has the same “problem”Edoardo Luppi
05/20/2025, 6:28 PMturansky
05/20/2025, 6:40 PMShort it works as requiredturansky
05/20/2025, 6:41 PMturansky
05/20/2025, 6:42 PMShortEdoardo Luppi
05/20/2025, 6:46 PMByte? With Short I'm forced to unsafe cast, as converting to a byte will change the number representationturansky
05/20/2025, 6:46 PMturansky
05/20/2025, 6:48 PMUByte in common code and safe convertion to Short on final stage