[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Math::Infinity and Math::NaN

Martin DeMello

4/29/2005 4:41:00 AM

I think it'd be useful to define Infinity and NaN as constants (perhaps
within Math, if they'd "pollute" the top level). The way I see it,
there's no real reason not to, and right now one has to resort to clumsy
looking workarounds to get at them.

martin
4 Answers

Trans

4/29/2005 5:00:00 AM

0

Hi Martin,

The new version of Facets (0.7) has an Infinity class. Of course due
to it's add-on nature it isn't fully integrated into the rest of the
Ruby class system (yet) we're working on it. I will consider also a NaN
class.

Thanks,
T.

Martin DeMello

4/29/2005 5:15:00 AM

0

Trans <transfire@gmail.com> wrote:
> Hi Martin,
>
> The new version of Facets (0.7) has an Infinity class. Of course due
> to it's add-on nature it isn't fully integrated into the rest of the
> Ruby class system (yet) we're working on it. I will consider also a NaN
> class.

Why classes? They're simply constants of type Float (defined in the IEEE
standard), and ruby already does provide access to them, complete with
pretty printing. It's just that it's a bit roundabout - e.g. you have to
say a = 1.0/0 rather than a = Infinity.

martin

Mark Hubbart

4/29/2005 5:48:00 AM

0

On 4/28/05, Martin DeMello <martindemello@yahoo.com> wrote:
> I think it'd be useful to define Infinity and NaN as constants (perhaps
> within Math, if they'd "pollute" the top level). The way I see it,
> there's no real reason not to, and right now one has to resort to clumsy
> looking workarounds to get at them.

This has been talked about a few times before on the list... I think I
remember it being suggested that there might not be a portable way to
generate Infinity and NaN on every platform.

cheers,
Mark



Florian Groß

4/29/2005 12:04:00 PM

0

Martin DeMello wrote:

> Why classes? They're simply constants of type Float (defined in the IEEE
> standard), and ruby already does provide access to them, complete with
> pretty printing. It's just that it's a bit roundabout - e.g. you have to
> say a = 1.0/0 rather than a = Infinity.

Having them implemented in a custom way would let you use them portably.
(Negative) infinity is quite useful when working with Ranges even if it
does not consider itself equal to 1.0 / 0.0.