[Q] Reading little endian DOUBLES on big endian platforms

Baveco, Hans Hans.Baveco at wur.nl
Fri Dec 3 10:18:26 UTC 2004


I am too stupid to be able to write this method.
Until a #doubleAt:bigEndian: methods pops up I will use the workaround of swapping the bytes on big endian platforms and using #doubleAt: on the swapped bytes. It's not elegant and it may slow down the reading for Mac users, but it should work...

Hans



No trick. The method doesn't exist. If you need it you'll have to write your
own.

Cheers,
- Andreas

----- Original Message -----
From: "Baveco, Hans" <Hans.Baveco at w...>
To: "The general-purpose Squeak developers list"
<squeak-dev at l...>
Sent: Friday, December 03, 2004 9:39 AM
Subject: [Q] Reading little endian DOUBLES on big endian platforms


In my Shapes package I make extensive use of the ByteArray>>doubleAt: method
(in the *FFI category), to read little-endian DOUBLES from the contents of a
binary file stream. This #doubleAt: is part of the FFIPlugin, and maybe not
a good general thing to rely on (can it be absent in some Squeak
distributions)? On windows it works fine, but on Mac not (of course). There
doesn't seem to be a doubleAt:bigEndian: method available that allows me to
define the endianness, like there is for integers (longAt:bigEndian: &
shortAt:bigEndian:).

What is the trick here?

Hans




More information about the Squeak-dev mailing list