[Haskell-cafe] Int is broken [Was: Different answers on different machines]

Carter Schonwald carter.schonwald at gmail.com
Mon Jun 3 18:25:17 CEST 2013


GHC is not the spec, I am talking about GHC Haskell, not Haskell the
standard that I don't use.

On 32bit machines, GHC Int is 32bits. On 64bit GHC on 64bit machines Int is
64 bits.

If you have another well engineered suitable for wide use Haskell compiler
in mind, I'd love to try it out, but with interesting software you will be
using none portable features per target platform. And thats OK. Its a
tradeoff thats sometimes worth making.
On Jun 3, 2013 4:19 AM, "Tommy Thorn" <tt1729 at yahoo.com> wrote:

> On Jun 3, 2013, at 00:23 , Carter Schonwald <carter.schonwald at gmail.com>
> wrote:
>
> > Int is "native register sized integer"
>
> Actually it's not. Read the definition. Int is only guaranteed to be 29
> bits.
>
> Here's *one* _actual_ data point (from a 2.8 GHz i7, 64-bit code):
>
> time ./fib
> fib(43) = 701408733
>         3.27 real         3.27 user         0.00 sys
> time ./fib-safe
> fib(43) = 701408733
>         3.45 real         3.45 user         0.00 sys
>
> (NB: I do not check the n-1 and n-2 as it's trivial to see from a data
> flow analysis
> that the proceeding conditional guarantees that those can't overflow.
> The empty asm() is necessary to get GCC to generate comparable code).
>
>
>
>
> Obviously, for some examples this will be much worse, for others, much
> better, but without
> this implemented in GHC it will be difficult to measure.
>
> Tommy
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130603/6a056694/attachment.htm>


More information about the Haskell-Cafe mailing list