Integer overflow: Difference between revisions

Added XPL0 example.
(Added Wren)
(Added XPL0 example.)
Line 2,373:
2147483648
131073
</pre>
 
=={{header|XPL0}}==
XPL0 implements integers as signed values and ignores overflows. The
original version used 16 bits. Later versions (used on Rosetta Code) use
32 bits. All the following expressions cause overflows, and the program
continues with wrong results.
 
<lang XPL0>int N;
[N:= -(-2147483647-1);
IntOut(0, N); CrLf(0);
N:= 2000000000 + 2000000000;
IntOut(0, N); CrLf(0);
N:= -2147483647 - 2147483647;
IntOut(0, N); CrLf(0);
N:= 46341 * 46341;
IntOut(0, N); CrLf(0);
N:= (-2147483647-1)/-1;
IntOut(0, N); CrLf(0);
]</lang>
 
{{out}}
<pre>
-2147483648
-294967296
2
-2147479015
-2147483648
</pre>
 
772

edits