Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Please check what the NVgf macro expands to on the different platforms ....

The puzzle is that, for certain cases (ie the aforementioned Debian and Ubuntu builds of perl) it apparently expands to different things, depending upon how it is expanded.
I find that mostly:
sprintf(buff, "%.19" NVgf, SvNV(arg)); and sv_setpvf(keysv, "%.19" NVgf, SvNV(arg));
produce the same result.
That is, the string in "buff" is exactly the same as the string in the PV slot of "keysv".
However, on some systems, with perls whose NV is 'double', and for integer values that require more than 17 digits, the string in "buff" differs from the string in the PV slot of "keysv".

Corion has suggested that this might be explained in terms of differences between perl's sprintf() and libc's sprintf().
My only reason for doubting him is that in 15 years of fiddling around with (s)printf on these systems, I have encountered no such issue. (But as soon as I start trying to get NVgf to work as I expect with sv_setpvf, I hit issues.)

... and check what ANSI C and POSIX say that conversion is supposed to actually do

Yes ... I've had no luck in finding any info on "NVgf" anywhere.
However, I've just found that replacing:
sv_setpvf(keysv, "%.19" NVgf, SvNV(arg)); with sv_setpvf(keysv, "%.19g", SvNV(arg));
makes no difference at all (at least when NV is 'double').
Given that I reckon I know what "%.19g" should expand to, this would suggest that I don't really need to wonder about what NVgf expands to - rather concentrate more on what sv_setpvf is doing (and on Corion's suggestion).
Or just settle for the workaround that I've already got :-)


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

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?

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

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (7)
    As of 2021-01-26 17:14 GMT
    Find Nodes?
      Voting Booth?