------ art_128248_10421599.1153598623050 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 7/22/06, hadley wickham <h.wickham / gmail.com> wrote: > > irb(main):084:0> (-1.0/0.0) > => -Infinity > irb(main):086:0> (1.0/0.0) > => Infinity > > but > > irb(main):087:0> Infinity > NameError: uninitialized constant Infinity > from (irb):87 > from :0 > > is it possible to directly access/create a float representing positive > or negative infinity? > > Thanks, > > Hadley > > #!/usr/bin/ruby InfinityClass = Class.new Infinity = InfinityClass.new class << InfinityClass def new; Infinity end end class InfinityClass def method_missing(name, *args, &blk ) Infinity end def to_s; "biiig"; end end puts Infinity puts Infinity + 1 puts 3 * Infinity unfortunately in order to make the last work you have to redefine Fixnum#* etc etc which does not seem pratical and I suppose that Infinity should be returned under certain circumstances which means that in an expression like a op b, b could easily be Infinity :( Cheers Robert Infinity = " a heck of a long time" # Sorry could not resist I suppose you would like things like Infinity * 3 = Infinity etc. etc. -- Deux choses sont infinies : l'univers et la bóŐise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------ art_128248_10421599.1153598623050--