Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^5: Windows / Linux puzzler

by syphilis (Bishop)
on Mar 26, 2020 at 02:25 UTC ( #11114655=note: print w/replies, xml ) Need Help??


in reply to Re^4: Windows / Linux puzzler
in thread Windows / Linux puzzler

MS's library is known to not be as good as a gcc's


All that the linked example demonstrates is that there's a discrepancy in the %.20g formatting - it says nothing about the ability to assign values correctly.
If you compare the actual values by doing "%a" formatting on both the Linux and windows perls, you'll see that 0.1 is exactly the same double.
Also, I believe the OP's activestate perl was built with (mingw port of) gcc. They stopped using Microsoft compilers a few years ago.

ikegami's point is likely even more irrelevant than Veltro's.

Cheers,
Rob

Replies are listed 'Best First'.
Re^6: Windows / Linux puzzler
by ikegami (Pope) on Mar 26, 2020 at 21:36 UTC

    If you compare the actual values by doing "%a" formatting on both the Linux and windows perls, you'll see that 0.1 is exactly the same double.

    Your are correct. pack 'd' shows this more definitely.

    >perl -E"say sprintf '%vX', pack 'd>', $ARGV[0]" 0.1 3F.B9.99.99.99.99.99.9A
    $ perl -E'say sprintf "%vX", pack "d>", $ARGV[0]', 0.1 3F.B9.99.99.99.99.99.9A

    I believe the OP's activestate perl was built with (mingw port of) gcc

    It definitely allows mingw to be used to compile modules, but I don't know if that's what used to build Perl itself. (Update: perl -V hints that it uses mingw)

    I beleive Strawberry Perl uses mingw, and I used Strawberry Perl in the test in the earlier post. If so, there are pertinent differences in the libraries between mingw and gcc.

      there are pertinent differences in the libraries between mingw and gcc

      I think that with mingw, the MS runtime is still used by default for formatting of values.
      However, that is avoided (by building with -D__USE_MINGW_ANSI_STDIO) in recent versions of Strawberry Perl, beginning perl-5.26.0.
      (Look for "-D__USE_MINGW_ANSI_STDIO" in perl -V:ccflags)

      Of course, ActiveState don't build with -D__USE_MINGW_ANSI_STDIO.

      Cheers,
      Rob

        Nope, that doesn't make differences go away, seeing as I was using SP 5.30.2 downloaded and installed less than a week ago. That's newer than 5.26, yet the output was different that the perl built gcc on Unbuntu on WSL on the same machine. The SP build does have -D__USE_MINGW_ANSI_STDIO

        Strawberry Perl 5.30.2 on Windows:

        >perl -e"CORE::say $^X" C:\progs\sp5302x64\perl\bin\perl.exe >perl -v | find "This is" This is perl 5, version 30, subversion 2 (v5.30.2) built for MSWin32-x +64-multi-thread >perl -V:nvsize nvsize='8'; >perl -V:ccflags ccflags=' -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -D__USE_MINGW_ANSI_STD +IO -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SY +S -DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfields'; >perl -e"CORE::say sprintf '%.20g', 0.1" 0.10000000000000000555

        Self-built Perl 5.30.2 on Ubuntu 18.04 LTS on WSL on Windows:

        $ uname -a Linux tribble 4.4.0-18362-Microsoft #476-Microsoft Fri Nov 01 16:53:00 + PST 2019 x86_64 x86_64 x86_64 GNU/Linux $ perl -v | grep 'This is' This is perl 5, version 30, subversion 2 (v5.30.2) built for x86_64-li +nux-thread-multi $ perl -V:nvsize nvsize='8'; $ perl -e'CORE::say sprintf "%.20g", 0.1' 0.10000000000000001

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11114655]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2020-05-28 07:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (165 votes). Check out past polls.

    Notices?