# [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%29because
+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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140304/f4a015c0/attachment.html>