Haskell 64-bit digital type

I am writing a function in Haskell that deals with numbers exceeding the length of a 32 bit int. I can't find the type to do this, and I seem to be looking for the wrong terms.

It should be able to hold numbers about 2 ^ 40 long without losing accuracy

Example:

addTwo :: Int -> Int -> Int
addTwo a b = a + b

main :: IO()
main = do
    putStrLn ( show ( addTwo 700851475143 1 ) )
+5
source share
3 answers

For unlimited precision, use the Integer type. For 64 bits of precision, across platforms, use Data.Int.Int64. Both will be easy to find with Hoogle: http://haskell.org/hoogle/

+21
source

You need a data type Integerinstead of Int:

addTwo :: Integer -> Integer -> Integer
+7
source

Integer, , Int.

0

All Articles