Integer overflow: Difference between revisions

m
→‎{{header|Wren}}: Entry was messed up, fixed now.
m (→‎{{header|Wren}}: Entry was messed up, fixed now.)
Line 2,730:
However, within this overall framework, Wren also has an unsigned 32-bit integer sub-system when dealing with bitwise operations. All values are converted internally to such integers before the corresponding C bitwise operation is performed (Wren's VM is written in C) and can therefore overflow without warning. Fortunately, we can easily observe these effects by performing the operations required by the task and then (for example) right shifting them by 0 places.
<syntaxhighlight lang="ecmascript">var exprs = [-4294967295, 3000000000 + 3000000000, 2147483647 - 4294967295, 65537 * 65537]
 
for (expr in exprs) System.print(expr >> 0)</syntaxhighlight>
System.print("Unsigned 32-bit:")
for (expr in exprs) System.print(expr >> 0)</syntaxhighlight>
 
{{out}}
Results agree with those for the corresponding C entry above.
9,486

edits