How to? DoubleArray

Yoshiki Ohshima yoshiki at squeakland.org
Fri Feb 10 02:47:38 UTC 2006


  Andreas,

> >   Of course, it runs on both endianness.  Look at the
> > ShortIntegerArray, and other classes that implement
> > #restoreEndianness.
> 
> Actually, it's better *not* to look at #restoreEndianness - it's a red 
> herring (and the name is wrong, too). The method doesn't really 
> "restore" anything; all it does is swapping (byte, short, word) 
> quantities if called on a little endian platform (in other words, it's 
> always a no-op on big-enders and will be broken if called "the wrong 
> number of times" on little-enders[*]). A better place to look at is 
> ShortIntegerArray and friends (see the class-side methods, in particular 
> #startUp) since they have to implement endianness conversion manually 
> for lack of VM support.

  Good explanation.

  The "," after the word "ShortIntegerArray" meant that "look at
ShortIntegerArray", and then look at other classes with some endian
related issues^^;

> [*] Even the definition of "wrong number of times" depends on whether 
> the array in question was loaded in a big- or little-endian format, or 
> if it was internal to begin with. And of course, if you load a 
> little-endian array on a big-endian platform and expect 
> #restoreEndianness to fix that, it won't work either. Confused? Well, I 
> told you not to look there ;-)

  Yup.

  Still, if you really like to have DoubleArray, perhaps for the
reason to communicate with external libraries or for some other
reasons such as writing your own performance primitives on numbers
with better precision, you could do it, I think.

-- Yoshiki



More information about the Squeak-dev mailing list