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" <maxs...@gmail.com>
To: users@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

Reply via email to