FloatArray to ByteArray???

Raab, Andreas Andreas.Raab at disney.com
Mon Aug 7 23:04:02 UTC 2000


> If I wanted to send a collection of Floats to some Java app (via a 
> Socket), would it be best to create a FloatArray (with the Floats) 
> and convert it (the FloatArray) to a ByteArray then use sendData: 
> on the ByteArray instance?

	| ba |
	ba := ByteArray new: floatArray size * 4.
	1 to: floatArray size do:[:i|
		ba longAt: (i-1) * 4 + 1 "byte index!"
		   put: floatArray basicAt: i.
		   bigEndian: requestedByteSex
	].

> PS> Do instances of Float correspond to Java 'doubles'?

Yes.

  - Andreas





More information about the Squeak-dev mailing list