views:

147

answers:

4

Hello,

What in Haskell differs from Int ant Integer? In what documentation can i find such things?

Thank you

+6  A: 

Int is the type of machine integers, with guaranteed range at least -2^29 to 2^29 - 1, while Integer is arbitrary precision integers, with range as large as you have memory for.

http://www.haskell.org/pipermail/haskell-cafe/2005-May/009906.html

NullUserException
+1 for answering both questions.
kbrimington
+8  A: 

"Integer" is an arbitrary precision type: it will hold any number no matter how big, up to the limit of your machine's memory…. This means you never have arithmetic overflows. On the other hand it also means your arithmetic is relatively slow. Lisp users may recognise the "bignum" type here.

"Int" is the more common 32 or 64 bit integer. Implementations vary, although it is guaranteed to be at least 30 bits.

Source: The Haskell Wikibook. Also, you may find the Numbers section of A Gentle Introduction to Haskell useful.

bcat
it is guaranteed to be at least 30 bits. i have fixed it in the wikibook
newacct
Ah, gotcha. I fixed it in my answer as well.
bcat
A: 

Int is the C int, which means its values range from -2147483647 to 2147483647, while an Integer range from the whole Z set, that means, it can be arbitrarily large.

$ ghci
Prelude> (12345678901234567890 :: Integer, 12345678901234567890 :: Int)
(12345678901234567890,-350287150)

Notice the value of the Int literal.

SHiNKiROU
A: 

The Prelude defines only the most basic numeric types: fixed sized integers (Int), arbitrary precision integers (Integer), ...

...

The finite-precision integer type Int covers at least the range [ - 2^29, 2^29 - 1].

from the Haskell report: http://www.haskell.org/onlinereport/basic.html#numbers

newacct