infinity comparison

Hans-Martin Mosner hmm at heeg.de
Fri Sep 17 16:38:50 UTC 2004


Jarvis, Robert P. (Bob) (Contingent) wrote:

>Upon some reflection
>
>   A) I'm surprised it didn't trigger a floating point overflow caused by
>trying to convert 1000! to Float.
>   B) Float is probably not the best place for infinity to reside.  Perhaps
>a better solution would be to have an Infinity class (subclass of Number)
>with a singleton instance - this class could then define the appropriate
>comparison operations and voila!  No more problem.  Better yet, have a
>PositiveInfinity and NegativeInfinity class, thus leading to
>
>	1000 factorial < PositiveInfinity value		"--> true"
>	1000 factorial * -1 > NegativeInfinity value	"--> true"
>
>That would match well with the IEEE floating-point standard's concept of
>positive and negative infinities.
>
>Bob Jarvis
>Compuware @ Timken
>
>  
>

VisualWorks has been doing it that way for years, and it's really the 
right thing to do.
FP numbers are just approximations to real numbers, they should stay 
that way.
Everything else which has a workable mathematical definition can be an 
object with proper behaviors.
We don't accept floats as substitutes for fractions or really large 
integers, why should we accept them as infinities?

Cheers,
Hans-Martin




More information about the Squeak-dev mailing list