[fpc-pascal] Writing floating points to steams

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Wed Jan 13 10:06:09 CET 2016


Serguei TARASSOV wrote:
> On 13/01/2016 08:47, fpc-pascal-request at lists.freepascal.org wrote:
>> On 2016-01-12 10:45, Torsten Bonde Christiansen wrote:
>>> Since TStream doesn't have any native WriteFloat/Double and the likes,
>>> some conversion is needed - but what is a good strategy for this?
> Depends on size constraints.
> In the simple case you should convert float to locale-independent string 
> value (no spaces, no commas separators) then write it.
> If the size does matter, you may convert float to corresponding byte 
> array then write it.

Can I ask a naive question here please: does a binary stream store 
endianness anywhere? In other words, is there any indication that 
something running on ARM is about to get into trouble by reading 
something written by (big-endian) MIPS?

Should writing binary floating point to a stream note that it's IEEE 
format, just in case anybody ever tries to process it on a platform that 
supports alternatives?

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]



More information about the fpc-pascal mailing list