[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] Arrays and class



Or write the values individually as exactly the type you want:

myArray.do({ |value| f.putFloat(value) });

... that is, converting the individual values at the time of writing, rather than converting the array.

Converting the array implies necessarily making a new array, so if you don't want to make a copy, then I suppose converting the whole array is not really what you're after.

hjh


On Dec 28, 2008, at 9:01 PM, koonce@xxxxxxxxxxxxx wrote:


When writing arrays of numbers to a binary file, the arrays need to be FloatArrays, as in:

f = File( "test", "wb");

f.write( FloatArray[1.0, 2.0 ] ) ;

If you had something like

IntegerArray[ 1, 2 ] or Array[ 1.1, 2.1 ]

and you needed to change, not the values but, the array class to FloatArray for printing, how would you do it short of simply creating a FloatArray copy of the array?



: H. James Harkins
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman