Integer overflow: Difference between revisions

no edit summary
No edit summary
Line 1,708:
=={{header|Pike}}==
Pike transparently promotes int to bignum when needed, so integer overflows do not occur.
 
=={{header|PowerShell}}==
Without explicit casting, as in this example, numbers which are too big are automatically promoted to [decimal] (128 bit, high precision floating point which is save for financial calculations), so no exception is raised.
 
https://docs.microsoft.com/en-us/dotnet/api/system.decimal?view=netframework-4.8#remarks
 
<lang powershell>
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
}
</lang>
 
=={{header|PureBasic}}==
Anonymous user