From: Mark Hubbart Date: 2004-09-02T06:24:28+09:00 Subject: Re: invisible Infinity On Sep 1, 2004, at 12:22 PM, Mohammad Khan wrote: > If you take a look in numeric.c > > > > Infinity and -Infinity is String and it is just a representation. > It is definitely, not a Constant. > > I am wrong, correct me please. What is displayed are just string representations of the value, but they are actually valid float values. Floats can be any floating point number, within a certain range, or: positive or negative Infinity (�Infinity), positive or negative Zero (�0.0), or not a number (NaN). They are all valid float values, but there is no way to access them, aside from calculating them. I'm not sure how often they would be useful, but it does seem strange that Infinity and NaN are the only float values that you can't state directly. cheers, Mark > > -- > Mohammad > > > On Wed, 2004-09-01 at 15:05, Brian Schroeder wrote: >> 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 > -- > Mohammad Khan > Legal Computer Solutions, Inc. > >