
Hello all, I found a good Haskell tutorial (second link on the Tutorials column) (now that I know how to run the programs in it). I have a question. What's the difference between the types Int and Integer? Likewise, what's the difference between the types Float and Double? Are those just synonims? Thanks for the help. Cheers, Daniel. -- /\/`) http://oooauthors.org /\/_/ http://opendocumentfellowship.org /\/_/ \/_/ I am not over-weight, I am under-tall. /

Daniel Carrera wrote:
Hello all,
I found a good Haskell tutorial (second link on the Tutorials column) (now that I know how to run the programs in it). I have a question. What's the difference between the types Int and Integer? Likewise, what's the difference between the types Float and Double? Are those just synonims?
Ah, that question is about core language types. The relevant section from the Haskell 98 Language Report (revised 2002): http://www.haskell.org/onlinereport/basic.html#sect6.4 The report, top link: http://www.haskell.org/onlinereport/ Though the report is not the best tutorial for some things.

Int is for bounded values -2**32 to 2**32 (I think... maybe 2**-31 and
2**31 or less if it's boxed?) based on the underlying machine
representation. Integer is unbounded (arbitrary precision, i.e.
7489571948579148758174534 is a valid Integer). Double is for floating
point values corresponding to C doubles, in hardware (on 32 bit
machines, 64 bit entities) and Floats are half that precision, i.e. 32
bits on 32 bit machines, corresponding to C floats.
see http://www.haskell.org/onlinereport/basic.html#sect6.3 and
http://www.haskell.org/onlinereport/basic.html#sect6.4 for more info.
Jared.
On 12/18/05, Daniel Carrera
Hello all,
I found a good Haskell tutorial (second link on the Tutorials column) (now that I know how to run the programs in it). I have a question. What's the difference between the types Int and Integer? Likewise, what's the difference between the types Float and Double? Are those just synonims?
Thanks for the help.
Cheers, Daniel. -- /\/`) http://oooauthors.org /\/_/ http://opendocumentfellowship.org /\/_/ \/_/ I am not over-weight, I am under-tall. / _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- jupdike@gmail.com http://www.updike.org/~jared/ reverse ")-:"

Thanks for the info, and the link. I probably should have guessed the Double vs Float one. I did program in C a while ago... Cheers, Daniel. Jared Updike wrote:
Int is for bounded values -2**32 to 2**32 (I think... maybe 2**-31 and 2**31 or less if it's boxed?) based on the underlying machine representation. Integer is unbounded (arbitrary precision, i.e. 7489571948579148758174534 is a valid Integer). Double is for floating point values corresponding to C doubles, in hardware (on 32 bit machines, 64 bit entities) and Floats are half that precision, i.e. 32 bits on 32 bit machines, corresponding to C floats.
see http://www.haskell.org/onlinereport/basic.html#sect6.3 and http://www.haskell.org/onlinereport/basic.html#sect6.4 for more info.
Jared.
On 12/18/05, Daniel Carrera
wrote: Hello all,
I found a good Haskell tutorial (second link on the Tutorials column) (now that I know how to run the programs in it). I have a question. What's the difference between the types Int and Integer? Likewise, what's the difference between the types Float and Double? Are those just synonims?
Thanks for the help.
Cheers, Daniel. -- /\/`) http://oooauthors.org /\/_/ http://opendocumentfellowship.org /\/_/ \/_/ I am not over-weight, I am under-tall. / _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- jupdike@gmail.com http://www.updike.org/~jared/ reverse ")-:" _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- /\/`) http://oooauthors.org /\/_/ http://opendocumentfellowship.org /\/_/ \/_/ I am not over-weight, I am under-tall. /

Am Montag, 19. Dezember 2005 01:10 schrieb Jared Updike:
Int is for bounded values -2**32 to 2**32 (I think... maybe 2**-31 and 2**31 or less if it's boxed?) based on the underlying machine representation.
Not really true. As far as I remember, the Haskell Report just says that Int covers at least the integers from -2^27 to 2^27 - 1. The range for Int can be higher than the range just given. For 32-bit machines it will probably be -2^31 to 2^31 - 1 but there's no guarantee for that.
[...]
Jared.
Best wishes, Wolfgang

On Monday 19 December 2005 11:26, Wolfgang Jeltsch wrote:
Am Montag, 19. Dezember 2005 01:10 schrieb Jared Updike:
Int is for bounded values -2**32 to 2**32 (I think... maybe 2**-31 and 2**31 or less if it's boxed?) based on the underlying machine representation.
Not really true. As far as I remember, the Haskell Report just says that Int covers at least the integers from -2^27 to 2^27 - 1. The range for Int can be higher than the range just given. For 32-bit machines it will probably be -2^31 to 2^31 - 1 but there's no guarantee for that.
http://www.haskell.org/onlinelibrary/basic.html 6.4 Numbers ... The finite-precision integer type Int covers at least the range [ - 2^29, 2^29 - 1]. As Int is an instance of the Bounded class, maxBound and minBound can be used to determine the exact Int range defined by an implementation. ... Ben
participants (5)
-
Benjamin Franksen
-
Chris Kuklewicz
-
Daniel Carrera
-
Jared Updike
-
Wolfgang Jeltsch