Interesting - thanks for persisting.

When I revert to an older Strawberry Perl that wasn't built with -D__USE_MINGW_ANSI_STDIO (5.24.1 / MSWin32-x64-multi-thread) I get the same as on Ubuntu:
C:\_64\strawberry5.24.1>perl -e"CORE::say sprintf '%.20g', 0.1" 0.10000000000000001 C:\_64\strawberry5.24.1>
I don't think that there's a lot of significance in the output of '%.20g' formatting of doubles.
As you're probably aware, both 0.10000000000000001 and 0.10000000000000000555 will assign to the same double anyway.
Both a 20-decimal-digit value, and that same value rounded to 17 decimal digits, will assign to the same double (unless something is buggy).

If the intention of "%.20g" formatting of 0.1 is to get the closest 20-decimal digit approximation to the double 0.1, then the latter is correct, and the former (ie the value consistently provided by Ubuntu) is incorrect:
C:\>perl -MMath::MPFR=":mpfr" -le "$x=Math::MPFR->new('0.1'); $base=10 +; $digits=20; Rmpfr_out_str($x, $base, $digits, MPFR_RNDN);" 1.0000000000000000555e-1 C:\>
Perhaps Linux has some catching up to do.
Even VC++ 2017 and later are "getting it right". On perl-5.30.0, MSWin32-x64-multi-thread, built with VC++ 2019:
C:\>perl -e"CORE::say sprintf '%.20g', 0.1" 0.10000000000000000555 C:\>
I'm not exactly sure when VC++ started "getting it right". I know it was some time after VC++ 2010.

Cheers,
Rob

In reply to Re^9: Windows / Linux puzzler by syphilis
in thread Windows / Linux puzzler by lbrandewie

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.