RosettaCodeData/Task/Integer-overflow/PowerShell/integer-overflow.psh

31 lines
878 B
Plaintext

try {
# All of these raise an exception, which is caught below.
# The try block is aborted after the first exception,
# so the subsequent lines are never executed.
[int32] (-(-2147483647-1))
[int32] (2000000000 + 2000000000)
[int32] (-2147483647 - 2147483647)
[int32] (46341 * 46341)
[int32] ((-2147483647-1) / -1)
[int64] (-(-9223372036854775807-1))
[int64] (5000000000000000000+5000000000000000000)
[int64] (-9223372036854775807 - 9223372036854775807)
[int64] (3037000500 * 3037000500)
[int64] ((-9223372036854775807-1) / -1)
[uint32] (-4294967295)
[uint32] (3000000000 + 3000000000)
[uint32] (2147483647 - 4294967295)
[uint32] (65537 * 65537)
[uint64] (-18446744073709551615)
[uint64] (10000000000000000000 + 10000000000000000000)
[uint64] (9223372036854775807 - 18446744073709551615)
[uint64] (4294967296 * 4294967296)
}
catch {
$Error.Exception
}