2020-01-15 22:18:07 +01:00
|
|
|
/* Test what happens for Integers that are to big for 32bits
|
|
|
|
2147483647 (=0x7FFFFFFF) is the biggest integer in 32bits (IntMAX)
|
|
|
|
*/
|
|
|
|
class Main {
|
|
|
|
void main() {
|
|
|
|
int x,y,z;
|
|
|
|
x = 2147483647;
|
|
|
|
write( x ); writeln();
|
|
|
|
/* add 1 to IntMax and output it */
|
|
|
|
write( x + 1); writeln();
|
|
|
|
|
|
|
|
/* read an int bigger than IntMAX */
|
|
|
|
x = read();
|
|
|
|
write(x); writeln();
|
|
|
|
|
|
|
|
/* performe some operation that should generate an int overflow */
|
2020-01-15 22:30:09 +01:00
|
|
|
x = 21474836400;
|
2020-01-15 22:18:07 +01:00
|
|
|
y = 60000;
|
|
|
|
write( x + y); writeln();
|
|
|
|
z = 20000000;
|
|
|
|
write( y * z); writeln();
|
|
|
|
write( (y * z) ); writeln();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|