[Haskell-cafe] Simple newbie question - Int and Integer
Gregory Propf
gregorypropf at yahoo.com
Thu Jul 12 15:10:35 EDT 2007
Heh, talk about overflow behavior. Here's what GHC does on my 64 bit machine. Note: you need to turn on -fglasgow-exts to force the types this way interactively. As for the tutorials, I have like 10 of them open in different Firefox tabs to different places. Mostly I've been reading up on IO, Monads and other advanced stuff while ignoring basic things I probably should have learned first.
Prelude> let i::Int = 2^62
Prelude> i
4611686018427387904
Prelude> let i::Int = 2^63
Prelude> i
-9223372036854775808
Prelude> let i::Int = 2^64
Prelude> i
0
Prelude> let i::Int = 2^100
Prelude> i
0
Clearly a job for Integer. -Greg
----- Original Message ----
From: Stefan O'Rear <stefanor at cox.net>
To: Andrew Coppin <andrewcoppin at btinternet.com>
Cc: haskell-cafe at haskell.org
Sent: Thursday, July 12, 2007 11:48:15 AM
Subject: Re: [Haskell-cafe] Simple newbie question - Int and Integer
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
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe at haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
____________________________________________________________________________________
Bored stiff? Loosen up...
Download and play hundreds of games for free on Yahoo! Games.
http://games.yahoo.com/games/front
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070712/550d5f9f/attachment.htm
More information about the Haskell-Cafe
mailing list