Efficiently importing/export GMP floats
tg at gmplib.org
Wed Jan 19 20:13:05 CET 2011
Patrick Pelissier <patrick.pelissier at gmail.com> writes:
> It might therefore make sense to update to a coherent format for GMP and
> MPFR, using function names not to be confused with mpz_out_raw/mpz_inp_raw.
> * The format should by byte-oriented, not 32-bit oriented.
Why do you prefer the format to be byte-oriented?
It is portable, and should be easy to implement portably across a wide
range of systems.
I don't now how to portably read and writ 32-bit quantities. Using getw
is not portable.
To consume less space?
Won't it make some compatibility problems across systems where a char is 8 bits
and systems where a char is 16 bits (or 32 bits)?
It is not so much a question about what size the char type might have.
What matters is what stdio supports.
Which systems do not provide an 8bit integer type? I'd assume wchar_t
were used for larger charsets.
> * "Network byte order" should be used, i.e., most significant byte first.
Do you have a practical example of why it is better?
It is not "better" in a way that allows one to produce an example. It
is the standard external byte order since epoch. Of course, standards
are ust standards, so if there are good reasons, one may choose to
deviate from them.
More information about the gmp-discuss