1.0 / 0.0 is not infinite

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

1.0 / 0.0 is not infinite

Henk-Jan van Tuyl

I tried:
   Hugs> 1.0 / 0.0
   1.#INF

   Hugs> isInfinite $ 1.0 / 0.0
   False
in WinHugs (Version: Sep 2006)

When the same is entered in GHCi, the result is True, as expected.

The definition of isInfinite in Prelude is:
   isInfinite  _ = False

An better definition could be as in the following:
   Hugs> let isInfinite' x = x == (1.0 / 0.0) in isInfinite' (3.1416 / 0.0)
   True


--
Met vriendelijke groet,
Henk-Jan van Tuyl


--
http://functor.bamikanarie.com
http://Van.Tuyl.eu/
--


_______________________________________________
Hugs-Bugs mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/hugs-bugs
Reply | Threaded
Open this post in threaded view
|

Re: 1.0 / 0.0 is not infinite

Neil Mitchell
Hi Henk,

>    Hugs> isInfinite $ 1.0 / 0.0
>    False

If you look at the library code it isn't entirely surprising:

instance RealFloat Float where
    isNaN       _ = False
    isInfinite  _ = False
    isDenormalized _ = False
    isNegativeZero _ = False
    isIEEE      _ = False

I guess the fix is to use your version in the isInfinite part. Some of
the others might want fleshing out too. I'm not sure if this is a
Windows only issue, or just a general Hugs thing.

Thanks

Neil
_______________________________________________
Hugs-Bugs mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/hugs-bugs