$ perl -wE'printf"%.0e\n",2 ** -1074'

Yes, if you know in advance the minimum number of digits needed then you can certainly feed that precision to printf() as you have done.
But, in general, one doesn't know that number.

For the given example, "%.0e" is fine because the following condition is true when $prec is 0:
sprintf "%.${prec}e", 2 ** -1074 == 2 ** -1074
But replace "2 ** -1074" with "3 ** 0.5", and the condition is untrue if $prec is 0. What's the minimum value for $prec that will render the condition true for 3 ** 0.5 ?
I haven't checked, but if nvtype is "double" it's probably 16, definitely not greater than 16, and unlikely to be less than 15.
Python3 (and the algorithm I've coded up) will output that minimum precision, without the need for anyone to calculate a "$prec" and feed it to printf().

Only thing I don't currently have is access to a widely available and well tested implementation of the algorithm for "long double" and "__float128" NVs - one that I can use to double-check that my own implementation is behaving correctly and standardizing the output appropriately.
And that's what I'm seeking.

Cheers,
Rob

In reply to Re^2: [OT] Accessing python3's print() of floating point values by syphilis
in thread [OT] Accessing python3's print() of floating point values 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, 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.