[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: IEEE Inf and NaN support for numbers.c

From: Marius Vollmer
Subject: Re: IEEE Inf and NaN support for numbers.c
Date: 07 May 2002 00:39:25 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Marius Vollmer <address@hidden> writes:

> Ok.  I think we should follow PLT Scheme here.  I will apply your
> patch and make the necessary changes.

Done.  Please play with it and tell me whether you like the changes I

        numbers.c (mem2ureal): Recognize "inf.0" and "".
        (scm_even_p, scm_odd_p): Treat infinity as even and odd.
        (iflo2str): Don't output a '+' for negative numbers or for Inf and
        NaN.  They will provide their own sign.
        (scm_divide): Only allow divides by inexact zeros.  Dividing by
        exact zeros still signals an errors.

Here is the NEWS entry:

    ** There is support for Infinity and NaNs.

    Following PLT Scheme, Guile can now work with infinite numbers and

    There is new syntax for numbers: "+inf.0" (infinity), "-inf.0"
    (negative infinity), "+nan.0" (not-a-number), and "-nan.0" (same as
    "+nan.0").  These numbers are inexact and have no exact counterpart.

    Dividing by an inexact zero returns +inf.0 or -inf.0, depending on the
    sign of the dividend.  The infinities are integers, and they answer #t
    for both 'even?' and 'odd?'. The +nan.0 value is not an integer and is
    not '=' to itself, but '+nan.0' is 'eqv?' to itself.

    For example

        (/ 1 0.0)
        => +inf.0

        (/ 0 0.0)
        => +nan.0

        (/ 0)
        ERROR: Numerical overflow

PLT Scheme does also distinguish plus and minus zero:

    (= 0.0 -0.0)
    => #t


    (eqv? 0.0 -0.0)
    => #f

I think we should do this as well.  John, how would one test for the
sign of zero?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]