[Newbies] Floats

Levente Uzonyi leves at elte.hu
Fri Nov 5 22:03:10 UTC 2010

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 

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 ].


> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

More information about the Beginners mailing list