Math::Infinity and Math::NaN

M

Martin DeMello

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
 
T

Trans

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.
 
M

Martin DeMello

Trans said:
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
 
M

Mark Hubbart

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
 
F

Florian Groß

Martin said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top