[Newbies] Floats

Mateusz Grotek unoduetre at poczta.onet.pl
Mon Nov 8 23:54:59 UTC 2010


Levente Uzonyi pisze:
> On Fri, 5 Nov 2010, Mateusz Grotek wrote:
> 
>> How to write Floats to a file. Is using at:1 and at: 2 the only method
>> of doing it. If so, why there is no support for Float writing in streams?
> 
> If the file is binary, then you can use #nextWordsPutAll:. Here's an
> example:
> 
> FileStream newFileNamed: 'BinaryFloatTest.txt' do: [ :file |
>     file binary.
>     file nextWordsPutAll: 1.2345 ].
> 
> It will store the words in big-endian format.
> If the file is not binary, then you can use #printOn: or #storeOn::
> 
> FileStream newFileNamed: 'FloatTest.txt' do: [ :file |
>     1.2345 printOn: file ].
> 
> 
> Levente
> 
> 

Thanks.



More information about the Beginners mailing list