[Haskell-cafe] Simple newbie question - Int and Integer

Stefan O'Rear stefanor at cox.net
Thu Jul 12 14:01:34 EDT 2007


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 at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070712/de93e005/attachment.bin


More information about the Haskell-Cafe mailing list