Math::Infinity and Math::NaN

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

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.

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

···

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.

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

···

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.

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.