in reply to Re^11: Introspection into floats/NV
in thread Introspection into floats/NV

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.)