in reply to Re^3: [OT] Endianness and extended precision (80-bit) long doubles
in thread [OT] Endianness and extended precision (80-bit) long doubles

Quoth  perldoc -f pack on my 5.8.9 Perl:

D   A long double-precision float in the native format.
    (Long doubles are available only if your system supports long
    double values _and_ if Perl has been compiled to support those.
    Causes a fatal error otherwise.)
Also see pack. I'm not sure about the red coloration; maybe it flags a feature not supported by all word widths/compilation options. (Actually, I suspect a documentation problem since everything in the table (update: including things like  x X @ that are as old as the hills) from line 41 on is both red and italic.)


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^5: [OT] Endianness and extended precision (80-bit) long doubles
by syphilis (Archbishop) on Aug 26, 2019 at 06:20 UTC
    Long doubles are available only if your system supports long double values _and_ if Perl has been compiled to support those.

    Yes - I ran the one liner on a build of perl-5.30.0 whose NV was long double.
    Not sure how far back the "D" option goes, but it's available in 5.8.8 onwards, at least.

    With recent perls we can ask for either little endian or big endian outputs - eg (on Windows):
    C:\_32>perl -le "print unpack 'h*', pack 'D<', sqrt 2;" 4846ed9f333f405bfff3000000000000 C:\_32>perl -le "print unpack 'h*', pack 'D>', sqrt 2;" 000000000000f3ff5b403f339fed4648
    However, I think the "big endian" output given here is simply the reverse of what was found on my machine.
    I don't think there's any basis to assume that it displays what's stored on an actual big endian machine.

    Cheers,
    Rob
Re^5: [OT] Endianness and extended precision (80-bit) long doubles
by Marshall (Canon) on Aug 26, 2019 at 16:06 UTC
    Yes, this red color gave me pause. Since this D feature appears in 5.8.9, I have no idea what the difference in text color means. Maybe if nobody knows what it means, the red color should be removed as a doc fix?

    oh...I see .. perhaps the red means that Perl has to be compiled in a certain way for the feature to "work"? Right now I'm using Perl 25.24 compiled for 64 bit. I suspect that means that long double is available? Almost all of my work is with integers and text. as another "oh...", I remember some benchmark testing that a Phd student did for me from ASM class on float performance with modern Intel processors. There are more transistors in the math unit than in the main CPU. The result was that float operations are about the same as integer ops which surprised me.

      ... I have no idea what the difference in text color means.

      I strongly suspect this is just a documentation bug. As I wrote here, the red/italic rendering appears at a certain line and continues to the end of the table. The template operators (symbols?) (update: specifiers?) so highlighted include ancient  x X @ operators. This highlighting is present even in the earliest on-line documentation: 5.6.0!

      Update: The red/italic highlighting always appears at the line

      d     A double-precision float in the native format.
      even though the layout of the template specifier table changes over documentation versions so that the number of this line changes: line 46 in 5.6.0; line 41 in 5.30.0. (Update: I also don't see any note in the documentation assigning any special meaning to red and/or italic highlighting.)


      Give a man a fish:  <%-{-{-{-<

        Interestingly, the competing documentation renderer shows no such problems: pack on perldoc.pl.

        map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]