ghc's Int is 32-bit on 32-bit platforms, according to maxBound.
On Mon, 21 Jan 2013 02:26:34 +0100 Benoit T
wrote:
> On Mon, Jan 21, 2013 at 01:17:17AM +0200, mip...@meta.ua wrote:
> > The program looks like this:
> >
> > --***
> > factorial :: Int->Int
> > factorial n = pro
On Mon, Jan 21, 2013 at 01:17:17AM +0200, mip...@meta.ua wrote:
> The program looks like this:
>
> --***
> factorial :: Int->Int
> factorial n = product [1..n]
>
> main = do
> print $ factorial 50
> --***
>
> And that yields "0" (no errors). Is it
Integer overflow. factorial 50 mod 2^32 = 0.
Change "Int" to "Integer" to get the correct result
(30414093201713378043612608166064768844377641568960512).
On Mon, Jan 21, 2013 at 12:17 AM, wrote:
> The program looks like this:
>
> --***
> factorial :: Int->Int
>
The program looks like this:
--***
factorial :: Int->Int
factorial n = product [1..n]
main = do
print $ factorial 50
--***
And that yields "0" (no errors). Is it a bug or feature? :)
__
Акция! Скидка до - 50% на колготы