[Haskell-cafe] abs minBound < (0 :: Int) && negate minBound == (minBound :: Int)

Brandon Allbery allbery.b at gmail.com
Mon Aug 19 19:46:16 CEST 2013


On Mon, Aug 19, 2013 at 11:43 AM, Kyle Miller <kmill31415 at gmail.com> wrote:

> Or, three other options: 1) make MIN_INT outside the domain of abs, 2)
> make the range of abs be some unsigned int type, or 3) use Integer (i.e.,
> use a type which actually represents integers rather than a type which can
> only handle small integers).
>

I think I would just document that Int is intended to represent a machine
word and therefore inherits the behavior of machine words, behavior at its
extrema is subject to the CPU behavior as a result, and if consistent
behavior is required then Integer should be used. (Indeed, it should
probably note that Int is a performance hack; but then you run into all the
Data.List etc. functions that use it.)

-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130819/f103e985/attachment.htm>


More information about the Haskell-Cafe mailing list