Henry98
Henry98

Reputation: 571

minBound and maxBound return wrong number for Int

A fixed-precision integer type with at least the range [-2^29 .. 2^29-1]. The exact range for a given implementation can be determined by using minBound and maxBound from the Bounded class.

This came straight from hackage.haskell.org.

According to both hackage.haskell.org and learnyouahaskell.com, what I'm supposed to get is -2147483648 for minBound and 2147483648 for maxBound.

When I actually run it myself, I get this result :

enter image description here

Apologies if this is a really stupid question. I'm new to Haskell and was testing around to see how things worked.

Am I doing something wrong?

Upvotes: 8

Views: 366

Answers (1)

luqui
luqui

Reputation: 60463

Ints are only guaranteed to have at least that range. Ints on your platform appear to be 64 bits. Compare with 2^63:

ghci> 2^63
9223372036854775808

Upvotes: 12

Related Questions