Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

minBound and maxBound return wrong number for Int

Tags:

haskell

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?

like image 587
Henry98 Avatar asked Aug 20 '15 21:08

Henry98


Video Answer


1 Answers

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
like image 96
luqui Avatar answered Sep 21 '22 17:09

luqui