Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

sv_setpvf, which is implemented by Perl_sv_vcatpvfn_flags does not use sprintf directly. Some internal parts will be be handled by sprintf, but a lot of that depends on how perl is configured.

Assuming this you are not using a quadmath or longdouble build, %.19g is special cased to use SNPRINTF_G, which is a macro for Gconvert which is a macro determined at Configure time and can point to several different functions.

On my Ubuntu system, it is using gcvt:

$ perl -V:d_Gconvert
d_Gconvert='gcvt((x),(n),(b))';

On my macOS system, it is using sprintf:

$ perl -V:d_Gconvert
d_Gconvert='sprintf((b),"%.*g",(n),(x))';

The perlclib documentation explicitly says that perl functions tend not to use the standard library. While it documents how to do things "the Perl way", it doesn't say that the functions will behave identically.

I'm not entirely clear if this is a bug or not. The documentation for this is under sprintf in perlfunc. While this behavior would seem to be violating the spirit of specifying the width, it is technically within the maximum width being provided.


In reply to Re: [XS] Weird behaviour on some Linux systems by Haarg
in thread [XS] Weird behaviour on some Linux systems by syphilis

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (7)
    As of 2021-01-25 17:17 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Notices?