A completely different question is whether the generated content is really one hundred percent wrong.

The readers can judge for themselves if your post with the incorrect bits removed tells them the difference between d and F.

Perl `pack` Template Comparison: "d" vs "F" =========================================== Summary Table ------------- | Template | Type | Precision | Bits | Description + | |----------|--------|--------------|------|--------------------------- +---------| | "d" | double | XXXXXXXXXXXX | XX | XXXXXXXXXXXXXXXXXXXXXXXXXX +XXXXX | | "F" | XXXXXX | XXXXXXXXXXXX | XX | XXXXXXXXXXXXXXXXXXXXXXXXXX +XXXXX | Example Code ------------ use feature 'say'; my $x = 1/3; say "Xouble:"; say unpack("BXX", pack("d>", $x)); # Big-endian XXXXXX say "XXXXX:"; say unpack("BXX", pack("F>", $x)); # Big-endian XXXXX Difference Illustration ----------------------- my $x = 1/3; my $XXXXX_bin = unpack "BXX", pack "F>", $x; my $double_bin = unpack "BXX", pack "d>", $x; printf " XXXXX (XX-bit): %s\n", $XXXXX_bin; printf "Xouble (XX-bit): %s\n", $double_bin; Expected Output: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +XXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +XXXXXXXXXXXX IEEE 754 Format Summary ----------------------- | Precision | Sign | Exponent | Mantissa (Significand) | Bias | |-----------|------|----------|-------------------------|------| | XXXXX | 1 bit | 8 bits | 23 bits | 127 | | Double | 1 bit | 11 bits | 52 bits | 1023 | Usage Notes ----------- - Use "d" / "d>" if you want: - XXXXXXXXXXXXXXXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - Direct compatibility with XXXXXXXXXXXXXXXXXXXXXXXX - Use "F" / "F>" if you want: - XXXXXXXXXXXXXXXXXXX - Exact compatibility with XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Endianness Reminder ------------------- - d> and F> -> big-endian - d< and F< -> little-endian - d and F (no angle) -> native-endian (machine dependent)

(Formatting errors left in. Only substantive errors were removed.)


In reply to Re^12: Introspection into floats/NV by ikegami
in thread Introspection into floats/NV by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.