3 ms·
If only the JVM had included unsigned math.
by sitkack 9y ago
If only the JVM had included unsigned math.
- xxs 9y agothere is... 'char'; char is an unsigned 16bit primitive (of course, adding 2 chars results into an int and you need a cast but that's another story)
- pjmlp 9y agoLegend goes Gosling did not found anyone at his department that could answer all his questions about unsigned arithmetic, hence why he left it out from Java's initial design. However since Java 8, the java.lang numeric classes do support unsigned arithmetic. Yes it is a bummer that byte is signed, requiring extra math to simulate unsigned.
- kodablah 9y agoYup, I use those unsigned methods, e.g. https://github.com/cretz/asmble/blob/3cb439e887245f23bf876e8be7c68aa2ef1c920f/compiler/src/main/kotlin/asmble/compile/jvm/FuncBuilder.kt#L247 https://github.com/cretz/asmble/blob/3cb439e887245f23bf876e8.... Luckily WASM only has 32/64 bit integer arithmetic.