Re: Writing a structure
E. Robert Tisdale wrote:[color=blue]
> Rogério Brito wrote:[color=green]
>> The second option would be better, because, AFAIK, an exact binary
>> image may have problems with the size of the members of the
>> structure, with the alignment chosen by the compiler for the
>> members of the structure and even byte-endianness, if the output
>> file is to be used across different platforms.[/color]
>
> The "textual version" may have problems with precise representation
> of floating-point numbers.[/color]
Indeed. I had not thought about the case of floating point numbers and
the problems that some libraries might have writing their (differing)
representation to files.
But since the "binary dump version" might also have problems with this
(since one can't guarantee that the systems where the file is written
and where the file is read use the same size and organization of
floating point numbers) in addition to those that I pointed above, I'd
still choose the "textual version" before going for the "binary dump"
version.
Of course, nothing beats a properly done, specialized serialization library.
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Rogério Brito - rbrito@ime.usp. br - http://www.ime.usp.br/~rbrito
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
E. Robert Tisdale wrote:[color=blue]
> Rogério Brito wrote:[color=green]
>> The second option would be better, because, AFAIK, an exact binary
>> image may have problems with the size of the members of the
>> structure, with the alignment chosen by the compiler for the
>> members of the structure and even byte-endianness, if the output
>> file is to be used across different platforms.[/color]
>
> The "textual version" may have problems with precise representation
> of floating-point numbers.[/color]
Indeed. I had not thought about the case of floating point numbers and
the problems that some libraries might have writing their (differing)
representation to files.
But since the "binary dump version" might also have problems with this
(since one can't guarantee that the systems where the file is written
and where the file is read use the same size and organization of
floating point numbers) in addition to those that I pointed above, I'd
still choose the "textual version" before going for the "binary dump"
version.
Of course, nothing beats a properly done, specialized serialization library.
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Rogério Brito - rbrito@ime.usp. br - http://www.ime.usp.br/~rbrito
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Comment