Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Integer-overflow/Haskell/integer-overflow.hs
Normal file
26
Task/Integer-overflow/Haskell/integer-overflow.hs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import Data.Int
|
||||
import Data.Word
|
||||
import Control.Exception
|
||||
|
||||
f x = do
|
||||
catch (print x) (\e -> print (e :: ArithException))
|
||||
|
||||
main = do
|
||||
f ((- (-2147483647 - 1)) :: Int32)
|
||||
f ((2000000000 + 2000000000) :: Int32)
|
||||
f (((-2147483647) - 2147483647) :: Int32)
|
||||
f ((46341 * 46341) :: Int32)
|
||||
f ((((-2147483647) - 1) `div` (-1)) :: Int32)
|
||||
f ((- ((-9223372036854775807) - 1)) :: Int64)
|
||||
f ((5000000000000000000 + 5000000000000000000) :: Int64)
|
||||
f (((-9223372036854775807) - 9223372036854775807) :: Int64)
|
||||
f ((3037000500 * 3037000500) :: Int64)
|
||||
f ((((-9223372036854775807) - 1) `div` (-1)) :: Int64)
|
||||
f ((-4294967295) :: Word32)
|
||||
f ((3000000000 + 3000000000) :: Word32)
|
||||
f ((2147483647 - 4294967295) :: Word32)
|
||||
f ((65537 * 65537) :: Word32)
|
||||
f ((-18446744073709551615) :: Word64)
|
||||
f ((10000000000000000000 + 10000000000000000000) :: Word64)
|
||||
f ((9223372036854775807 - 18446744073709551615) :: Word64)
|
||||
f ((4294967296 * 4294967296) :: Word64)
|
||||
Loading…
Add table
Add a link
Reference in a new issue