[squeak-dev] Re: 32 bits single precision float number to a byte array

David T. Lewis lewis at mail.msen.com
Thu Feb 26 14:55:30 UTC 2009


On Thu, Feb 26, 2009 at 01:15:36AM -0800, Andreas Raab wrote:
> Serge Stinckwich wrote:
> >There is a primitive failed in ByteArray>>integerAt:put:size:signed with 
> > your solution ...
> 
> Ah, yes. This is the platform specific access for FFI and friends.
> 
> >Seems to work if i add bigEndian:true :
> 
> You're right. That is the correct solution.
> 
> Cheers,
>   - Andreas
> 
> >fltArray := FloatArray with: 42.0.
> >word := fltArray basicAt: 1.
> >bytes := (ByteArray new: 4) unsignedLongAt: 1 put: word bigEndian:true; 
> >yourself.

Note also that this does not work on a 64 bit host (e.g. 64 bit Linux).

Dave




More information about the Squeak-dev mailing list