[Haskell-cafe] abs minBound < (0 :: Int) && negate minBound == (minBound :: Int)
Nicolas Frisby
nicolas.frisby at gmail.com
Sun Aug 18 17:38:07 CEST 2013
The docs at
http://www.haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:gcd
give a NB mentioning that (abs minBound == minBound) is possible for
fixed-width types.
This holds, for example, at Int. It is also the case that (negate minBound
== minBound).
Two questions:
1) This behavior surprised me. Does it surprise enough people to include
a warning in the Haddock for abs and negate? IE Here.
http://www.haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Num
2) Is this a common behavior in other languages? My tinkering with gcc
suggests it does not support the value -2^63, but instead bottoms out at
(-2^63+1).
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130818/88da6042/attachment.htm>
More information about the Haskell-Cafe
mailing list