[BUG][FIX] FloatArrayIsZero

Frank Shearar frank.shearar at rnid.org.uk
Fri Apr 2 11:46:50 UTC 2004


> >>> "Alexander at Lazarevic.de" 04/02/04 09:18 >>>
>
>
> Installing Scamper into the latest 3.7alpha from SqueakMap will fail
> because of the following. (The bug is not in scamper, but that's how I
> found the bug)
>
> "Change Set:		FloatArrayIsZero
> Date:			2 April 2004
> Author:			Alexander at Lazarevic.de
>
> Division with FloatArrays will fail because of a missing
> isZero method.
> This just adds this method to the class FloatArray.
>
> Testcase :)
> 2.0 / #(1 2) asFloatArray
> "

I'm assuming you expect a FloatArray containing 2.0 and 1.0 from your sample
expression, right? That is, "return a FloatArray containing the result of
dividing 2.0 by the elements of #(1 2)".

At first I thought your change perfectly reasonable. But what does #isZero
actually mean for an array? I mean, we can talk about the zero vector, sure,
but a FloatArray (or ByteArray or IntegerArray) can't be zero because it's
not a magnitude - it's a collection.

Too, "2.0 / #(1 0) asFloatArray" won't raise a DivideByZero error (as it
should (by my interpretation of your test case)).

If you're thinking of a FloatArray as a vector (in the mathematical sense)
you can happily talk of "#(1 2) asFloatArray / 2" - that's part of what
makes something a vector space. But dividing a scalar by a vector makes no
sense in a vector space.

frank





More information about the Squeak-dev mailing list