[Haskell] Literal for Infinity

Jacques Carette carette at mcmaster.ca
Thu Sep 29 08:13:27 EDT 2005

The IEEE 754 standard says (fairly clearly) that +1.0 / +0.0 is one of 
the most 'stable'  definitions  of Infinity (in  Float at least).  
Throwing an exception is also regarded as a possibility in IEEE 754, but 
it is expected that that is not the default, as experience shows that 
that is a sub-optimal default.  Mathematical software (Maple, 
Mathematica, Matlab) have generally moved in that direction.

Almost all hardware implementations of float arithmetic now default to 
IEEE 754 arithmetic.  Having the arithmetic do 'something else' involves 
more CPU cycles, so users should generally complain if their system's 
arithmetic differs from IEEE 754 arithmetic without some deep reason to 
do so [there are some; read and understand William Kahan's papers for 


Yitzchak Gale wrote:

>While checking for floating-point overflow and
>underflow conditions, I tried to create a somewhat
>reliable cross-platform Infinity with the literal
>When GHC 6.4.1 reads this literal, it goes into a
>deep trance and consumes huge amounts of
>memory. Shouldn't it immediately recognize such a
>thing as Infinity?
>Is there a better way to check for Infinity?  I
>have not yet figured out how to check for NaN at
>all - because it is not equal to itself. Any
>BTW, I notice that Simon PJ proposed literals
>for Infinity and Nan several years ago:
>Did anything ever come out of this?
>Haskell mailing list
>Haskell at haskell.org

More information about the Haskell mailing list