infinity comparison

Lex Spoon lex at cc.gatech.edu
Sun Sep 19 23:27:03 UTC 2004


Travis Griggs <tgriggs at key.net> wrote:
> VW has a 'AT MetaNumerics'. It dates back to OW4.0, at least. It has 
> NotANumber, SomeNumber (coercion wrapper), Complex, Infinity and 
> Infintessimal, both of which keep track of their sign. However, it 
> doesn't interoperate with the base system really. IOW, with it loaded, 
> you don't start getting Infinity objects when an fp computation 
> produces an fp INF. -1 sqrt does not automatically make a Complex 
> object. So on and so forth.

A tricky issue here is that it is valuable to have the classic semantics
available somehow.  If you go look up a numeric algorithm, you will
frequently find algorithms that assume IEEE floating point.  In that
semantics, taking the square root of -1 is supposed to give you NaN, not
i.

That said, it seems very reasonable to have a separate IEEEFloat class
for those cases.  They might have to type something like "-1.0ieee".  

It does appear that we have to favor one semantics or the other.  [-1.0
sqrt] has to evaluate either to [Complex i] or to [NaN], which in turn
have to be different values.  Keystroke for keystroke, I'd guess that
for Smalltalk, sloppy intuitive arithmetic, where you'd prefer [Complex
i], is much more common than carefully tuned Floating point arithmetic,
so I'd guess we want to make [-1.0 sqrt] be [Complex i].

Assuming someone ever implements all this stuff of course!

-Lex



More information about the Squeak-dev mailing list