Jump to content

Integer overflow: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
(add RPL)
m (→‎{{header|Wren}}: Changed to Wren S/H)
Line 2,885:
 
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="ecmascriptwren">var exprs = [-4294967295, 3000000000 + 3000000000, 2147483647 - 4294967295, 65537 * 65537]
System.print("Unsigned 32-bit:")
for (expr in exprs) System.print(expr >> 0)</syntaxhighlight>
9,485

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.