
So what the hell is the difference between them? Int and Integer. They aren't synonyms clearly. What's going on? ____________________________________________________________________________________ Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more. http://mobile.yahoo.com/go?refer=1GNXIC

On Thu, Jul 12, 2007 at 10:58:38AM -0700, Gregory Propf wrote:
So what the hell is the difference between them? Int and Integer. They aren't synonyms clearly. What's going on?
stefan@stefans:/usr/local/src/ghcbuild$ ghci Loading package base ... linking ... done. ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.7.20070612, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \____/\/ /_/\____/|_| Type :? for help. Prelude> 1000000000000 :: Integer 1000000000000 Prelude> 1000000000000 :: Int -727379968 Prelude> Int is fifteen times faster, but vulnerable to overflow errors. Stefan

To be more precise, Int represents a machine-sized integer value, so it is
limited in size but doing math with Int values translates directly into math
on the processor. Integer can store integer values of arbitrary size, which
is useful sometimes but is of course a lot slower, since the pieces of an
Integer value have to be stored in some sort of list, and specialized code
is used to do arithmetic with Integers by operating on the pieces and
combining the results.
How have you been learning Haskell? I'm guessing this is probably covered
in most tutorials.
-Brent
On 7/12/07, Gregory Propf
So what the hell is the difference between them? Int and Integer. They aren't synonyms clearly. What's going on?
------------------------------ Don't be flakey. Get Yahoo! Mail for Mobilehttp://us.rd.yahoo.com/evt=43909/*http://mobile.yahoo.com/mailand always stay connectedhttp://us.rd.yahoo.com/evt=43909/*http://mobile.yahoo.com/mailto friends.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Gregory Propf wrote:
So what the hell is the difference between them? Int and Integer. They aren't synonyms clearly. What's going on?
Int = 32-bit integer. Integer = arbitrary precision integer. (See also Data.Integer and Data.Word, which provide signed and unsigned integers of other sizes.)

On Thu, Jul 12, 2007 at 07:39:09PM +0100, Andrew Coppin wrote:
Gregory Propf wrote:
So what the hell is the difference between them? Int and Integer. They aren't synonyms clearly. What's going on?
Int = 32-bit integer.
Int = 30 bits with undefined overflow behavior That "undefined" gives implementations the freedom to use bigger representations if convenient. GHC: 31, 32 or 64 bits (from source code) Hugs: 32 bits (only tested on a 32 bit computer) YHC: 32 or 64 bits (from source code) JHC: Buggy (maxBound :: Int is negative) Stefan

Stefan O'Rear wrote:
On Thu, Jul 12, 2007 at 07:39:09PM +0100, Andrew Coppin wrote:
Int = 32-bit integer.
Int = 30 bits with undefined overflow behavior
That "undefined" gives implementations the freedom to use bigger representations if convenient.
Personally, my rule of thumb is this: Int = some number Integer = some *big* number Int32 (or whatever) = I actually want it exactly THIS size. So I just use Int when I don't really care what size the integer is - mainly becuase *everything* seems to use Int and it saves on explicit type conversions all over the place. (I'm not actually too sure that Int *should* be used all over the place - but it'll never be changed, so...)

Gregory Propf
So what the hell is the difference between them? Int and Integer. They aren't synonyms clearly. What's going on?
http://www.haskell.org/haskellwiki/Learn_Haskell_in_10_minutes is a good starting point for answering this and similar questions.

Dave Bayer
Gregory Propf
writes: So what the hell is the difference between them? Int and Integer. They aren't synonyms clearly. What's going on?
http://www.haskell.org/haskellwiki/Learn_Haskell_in_10_minutes
is a good starting point for answering this and similar questions.
Err, wow! Word gets around fast. I wrote that up through about 1:00 am this morning, and I'm a little embarassed by it. I was thinking I'd let it hand around in my head and do a second pass in a day or two to make it more respectable; but hey, I'll swallow my embarassment if people find it helpful. :) -- Chris Smith
participants (6)
-
Andrew Coppin
-
Brent Yorgey
-
Chris Smith
-
Dave Bayer
-
Gregory Propf
-
Stefan O'Rear