Enum class
Pixel
pixel@mandrakesoft.com
23 Oct 2001 19:47:30 +0200
George Russell <ger@tzi.de> writes:
> (1) succ & pred. These appear for float to correspond to adding or subtracting
> 1.0. (I am finding this out by testing with ghci; it's not specified where
> it should be, in section 6.3.4 of the standard). Because of rounding errors,
> succ and pred fail many of the properties for float they have for integers, EG
> succ . pred = pred . succ = id
> succ x > x
> and so on.
Quite a few pbs with overflow on Int too:
i :: Int
i = 0x7fffffff
i_plus_1 = i+1
-- ghc : -2147483648
-- hugs: -2147483648
i_succ = succ i
-- ghc : *** Exception: Prelude.Enum.succ{Int}: tried to take `succ' of maxBound
-- hugs: -2147483648
j :: Int
j = 0x80000000
-- ghc : -2147483648
-- hugs: Program error: {primIntegerToInt 2147483648}
k :: Int
k = 0x100000000
-- ghc : 0
-- hugs: Program error: {primIntegerToInt 4294967296}
i':: Integer
i'= 0x7fffffff
i_plus_1' = i+1
-- ghc : 2147483648
-- hugs: 2147483648
i_succ' = succ i'
-- ghc : 2147483648
-- hugs: -2147483648