y
05/07/2025, 4:34 AMUInt?
typically in a strongly-typed language you would use an unsigned type for validation, but everything ever takes Int (for "Java reasons" which I do understand) so there's going to be conversions at the call site everywhere.Youssef Shoaib [MOD]
05/07/2025, 6:01 AMInt , sure, but you can always write wrappers around them if you know that they can handle `UInt`s tooy
05/07/2025, 8:14 AMInt, then the fact that UInt is wider is not helpful since it's going to fail the cast at the call site.y
05/07/2025, 8:16 AMIntKlitos Kyriacou
05/07/2025, 9:16 AMInt.MAX_VALUE, but something a lot smaller (such as a fixed number of digits). In that case, you would have to check the range anyway, irrespective of whether it's a UInt or an Int.
2. Casting from UInt using toInt() is a no-op in bytecode.
3. Java functions that take unsigned integers as int are usually fine with a UInt represented as a negative int. For example, Protobuf function UInt32Value.of(int) will create a large positive number from a negative int. Therefore you can do val x: UInt = ...; val y = UInt32Value.of(x.toInt())y
05/07/2025, 9:23 AMy
05/07/2025, 9:24 AMInt.MAX_VALUE needs to be rethought, but again, it's manageable. on par with other Java interop quirksKlitos Kyriacou
05/07/2025, 9:28 AM