When playing around with minBound for various instances, I tried
> minBound :: Int
=> -9223372036854775808
which seems reasonable.
However,
> abs minBound :: Int
=> -9223372036854775808
How is this possible? Shouldn't abs x >= 0, assuming x :: Int?
Is there some sort of understanding of semantics I am missing here?
Prelude> minBound :: Int
-9223372036854775808
Prelude> maxBound :: Int
9223372036854775807
Note that the number 9223372036854775808 is not representable as an integer. This is a consequence of the two's complement representation likely being used in the background here. The absolute value of minBound cannot be represented as a member of the type Int, so you end up getting an overflowing value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With