As titled,
From the specification, it seems I can make sure a value (x) could be evaluated to unsigned only by things like that: x >>> 0
. But as I know, here the ">>>" should be an operator rather that annotation. So, why does ASM.js have no annotation for unsigned?
http://asmjs.org/spec/latest/#annotations
Besides, as we know, type "int" should be signed by default in programming languages like C and C++, but why the same type "int" has no signedness in ASM.js?
What the specification says as below, but I do not quite get the point.
The int type is the type of 32-bit integers where the signedness is not known. In asm.js, the type of a variable never has a known signedness. This allows them to be compiled as 32-bit integer registers and memory words. However, this representation creates an overlap between signed and unsigned numbers that causes an ambiguity in determining which JavaScript number they represent. For example, the bit pattern 0xffffffff could represent 4294967295 or -1, depending on the signedness. For this reason, values of the int type are disallowed from escaping into external (non-asm.js) JavaScript code.
User contributions licensed under CC BY-SA 3.0