It would be helpful to show some code
Yes, it might have been clearer if I'd phrased the question in terms of pack/unpack.
On my 64-bit little-endian machine (Ubuntu-18.04), running a perl whose NV is the extended precision (80-bit) long double, I get:
$ perl -le 'print unpack "h*", pack "D", sqrt 2;'
4846ed9f333f405bfff3000000000000
If I ran the identical one-liner on a 64-bit
*big-endian* machine,running a perl whose NV is the extended precision (80-bit) long double, where would that substring of 12 consecutive zeroes appear ?
Would it still appear at the end of the string (as was the case on my little-endian machine), or would it appear at the beginning ?
I have long-standing C code in Math-MPFR (MPFR.xs) that presumes that the substring in question will appear at the end of the string, irrespective of endianess:
....
n = bits == 64 ? 10 : 16;
#ifdef MPFR_HAVE_BENDIAN /* Big Endian architecture */
for (i = 0; i < n; i++) {
#else
for (i = n - 1; i >= 0; i--) {
#endif
// code that does something with byte i
but I don't recall having ever established the correctness of that code for the big-endian case.
If it were incorrect, then the test suite should expose the error - but then I don't know if Math::MPFR has ever been built on a big-endian machine, using a perl whose NV is the 80-bit long double.
Cheers,
Rob
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.