[racket] Exact Infinity?

From: Neil Toronto (neil.toronto at gmail.com)
Date: Tue Mar 4 14:53:18 EST 2014

It was on [racket-bug], so it's kind of hard to find. Here it is:

     http://bugs.racket-lang.org/query/?cmd=view&pr=14232

Search for "Neil" on the page.

I think +inf and -inf could be added to the numeric tower with little to 
no effect on current programs. There would be no +nan, not only for 
backwards compatibility, but also for guarantees: if an exact result is 
well-defined (i.e. doesn't raise an error), it should be correct.

Neil ⊥

On 03/04/2014 11:24 AM, Robby Findler wrote:
> I think that Neil \bot posted on this subject in this forum at some
> point with a fairly optimistic message.
>
> Robby
>
>
>
> On Tue, Mar 4, 2014 at 11:54 AM, J. Ian Johnson <ianj at ccs.neu.edu
> <mailto:ianj at ccs.neu.edu>> wrote:
>
>     It's a bit of a philosophical problem to have an "exact" infinity.
>     Writing your own such wrappers should not be too much work. I've
>     done similar constructions in my own work in analysis, simply using
>     the symbol 'ω for infinity.
>     -Ian
>     ----- Original Message -----
>     From: "Max New" <maxsnew at gmail.com <mailto:maxsnew at gmail.com>>
>     To: users at racket-lang.org <mailto:users at racket-lang.org>
>     Sent: Tuesday, March 4, 2014 12:08:03 PM GMT -05:00 US/Canada Eastern
>     Subject: [racket] Exact Infinity?
>
>
>
>
>     I've been doing some work that uses a data structure that includes a
>     size that can be either a Natural number of Infinity ,a so-called
>     "extended natural number".
>
>
>     I've been using +inf.0 and gotten by using `<` and `infinite?` and
>     things have worked fine out of the box but now I need to take the
>     minimum of such numbers, but
>
>
>      > (min 0 +inf.0)
>     returns 0.0, an inexact 0. This behavior is expected:
>     http://docs.racket-lang.org/reference/generic-numbers.html?q=inf&q=min&q=min&q=list/c&q=-%3E&q=define/contract#%28def._%28%28quote._~23~25kernel%29._min%29%29
>     because +inf.0 (and +inf.f) is a floating point number and thus inexact.
>
>
>     I need to use exact naturals throughout however, so I can write a
>     wrapper that takes the floor of the number after a call to min or I
>     can define my own min that returns the original arguments.
>
>
>
>     (define (mymin a b)
>     (if (< a b) a b))
>
>
>     But would it be useful if exact infinities were added to the numeric
>     tower? I'll call them +inf and -inf. Most operations like +, * etc
>     could be defined easily though you would probably also want to add
>     an "exact" nan for say (+ +inf -inf). The operations would work
>     exactly the same way they do for inexact infinities, except
>     returning exact numbers when possible, so for example
>
>
>     (1 . / . +inf) ==> 0
>     (min 34 +inf) ==> 34
>
>
>     -Max Stewart New
>
>     ____________________
>        Racket Users list:
>     http://lists.racket-lang.org/users
>
>     ____________________
>        Racket Users list:
>     http://lists.racket-lang.org/users
>
>
>
>
> ____________________
>    Racket Users list:
>    http://lists.racket-lang.org/users
>


Posted on the users mailing list.