From: Robert Dober Date: 2006-07-23T05:03:46+09:00 Subject: Re: Infinity ------=_Part_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 wrote: > > irb(main):084:0> (-1.0/0.0) > =3D> -Infinity > irb(main):086:0> (1.0/0.0) > =3D> 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 =3D Class.new Infinity =3D 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 =3D " a heck of a long time" # Sorry could not resist I suppose you would like things like Infinity * 3 =3D Infinity etc. etc. --=20 Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_128248_10421599.1153598623050--