From: Brian Schroeder Date: 2004-09-02T04:05:22+09:00 Subject: Re: invisible Infinity On Wed, 01 Sep 2004 18:05:43 +0000, gabriele renzi wrote: > Hi gurus and nubys, > > I wonder, if you divide a Float by zero, you get Infinity: > >> a=10.0/0 > => Infinity > > > and you can even write code using Infinity like: > >> 0.upto(a) do |x| p x end > 0 > 1 > 2 > 3 > .. > > but if you try to access it directly you can't: > >> Infinity > NameError: uninitialized constant Infinity > from (irb):4 > > Should we be able to access Infinity directly? It seem a strange > unexplicable behaviour to me, that it exists but is not normally > accessible. I also was surprised, that Infinity is no predefined constant, as I used it in some algorithm where I needed to fill an Array with infinity, then iteratively reducing the values. In these cases infinity is much better than nil as a special value because it can be compared. So I declared 1.0/0.0 as Infinity and ready. But I regard it as against the pols. Greetings, Brian -- Brian Schr�der http://www.brian-schroeder.de/