Yep, got it, Thanks!

Cale Gibbard wrote:
Hmm...
let a = (maxBound :: Int)%1 in 1 < a && a < 1/2 == True


From the Ord instance for Ratio a
(x:%y) <  (x':%y')  =  x * y' <  x' * y

So the comparison for 1 < a looks like
1 * 1 < (maxBound :: Int) * 1
which is true.
And the comparison for a < 1/2 looks like
(maxBound :: Int) * 2 < 1 * 1
==> -2 < 1
which is again true!

If you want well-behaved rationals, I suppose you have to use Ratio Integer.

Hope this helps,
 - Cale

On 4/13/05, Bo Herlin <[EMAIL PROTECTED]> wrote:

Hi

How come

> foldr1 min [(maxBound::Int) % 1,1 % 2]
2147483647 % 1

but

> foldr1 min [2147483647 % 1,1 % 2]
1 % 2

Why???

/Bo Herlin
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe



_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to