<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">A spec for the the approach below might look something like this:<div><br><div>After 7.22.1.2, add:<br>&nbsp;<br>7.22.1.3&nbsp; &nbsp;The&nbsp;strfromflt function</div><div><br>Synopsis</div><div><br>#define&nbsp;__STDC_WANT_IEC_60559_BFP__<br>#include&nbsp;&lt;stdlib.h&gt;<br>int&nbsp;strfromflt(char * restrict s, size_t n, const char * restrict format, …);<br>&nbsp;<br>Descripton<br>&nbsp;<br>The&nbsp;strfromflt&nbsp;function is equivalent to&nbsp;snprintf&nbsp;(7.21.6.5) except the format&nbsp;string shall contain at most one conversion&nbsp;specifier, which, if present, shall&nbsp;be e, E, f, F, g, G, a, or A, with an optional l or L length modifier. Use of other&nbsp;format strings&nbsp;results in undefined behavior. [footnote]<br>&nbsp;<br>Returns<br>&nbsp;<br>The&nbsp;strfromflt&nbsp;function returns the values&nbsp;returned by&nbsp;snprintf&nbsp;(7.21.6.5), for&nbsp;valid input.<br>&nbsp;<br>[footnote] strfromflt&nbsp;may be equivalent to snprintf.</div><div><br></div><div>-Jim<br><div><br></div><div><br></div><div>Begin forwarded message:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1.0);"><b>From: </b></span><span style="font-family:'Helvetica'; font-size:medium;">Jim Thomas &lt;<a href="mailto:jaswthomas@sbcglobal.net">jaswthomas@sbcglobal.net</a>&gt;<br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1.0);"><b>Subject: </b></span><span style="font-family:'Helvetica'; font-size:medium;"><b>Re: [Cfp-interest] outstanding issues</b><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1.0);"><b>Date: </b></span><span style="font-family:'Helvetica'; font-size:medium;">April 11, 2012 10:57:41 AM PDT<br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1.0);"><b>To: </b></span><span style="font-family:'Helvetica'; font-size:medium;">CFP &lt;<a href="mailto:cfp-interest@ucbtest.org">cfp-interest@ucbtest.org</a>&gt;<br></span></div><br><div>This looks like an approach to consider. Freestanding implementations already need to support ellipsis notation. Instead of the 'Q' modifier we could have an optional 'L', which would cover all the standard floating types. <br><br>-Jim<br><br>On Apr 11, 2012, at 10:23 AM, Fred J. Tydeman wrote:<br><br><blockquote type="cite">On Tue, 10 Apr 2012 16:35:30 -0700 Jim Thomas wrote:<br></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">ISSUE 3: Would it be better to restrict the format specifiers <br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">that the strfrom functions have to support?<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I recently discovered that gcc has similar support.<br></blockquote><blockquote type="cite"><blockquote type="cite">From the info pages on libquadmath:<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">3.2 `quadmath_snprintf' -- Convert to string<br></blockquote><blockquote type="cite">============================================<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">The function `quadmath_snprintf' converts a `__float128' floating-point<br></blockquote><blockquote type="cite">number into a string. &nbsp;It is a specialized alternative to `snprintf',<br></blockquote><blockquote type="cite">where the format string is restricted to a single conversion specifier<br></blockquote><blockquote type="cite">with `Q' modifier and conversion specifier `e', `E', `f', `F', `g',<br></blockquote><blockquote type="cite">`G', `a' or `A', with no extra characters before or after the<br></blockquote><blockquote type="cite">conversion specifier. &nbsp;The `%m$' or `*m$' style must not be used in the<br></blockquote><blockquote type="cite">format.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Syntax<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;`int quadmath_snprintf (char *s, size_t size, const char *format,<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;...)'<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">_Arguments_:<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;S &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;output string<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;SIZE &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;byte size of the string, including tailing NUL<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;FORMAT &nbsp;&nbsp;&nbsp;&nbsp;conversion specifier string<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Example<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#include &lt;quadmath.h&gt;<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#include &lt;stdlib.h&gt;<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#include &lt;stdio.h&gt;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int main ()<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;__float128 r;<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int prec = 20;<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int width = 46;<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char buf[128];<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;r = 2.0q;<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;r = sqrtq (r);<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int n = quadmath_snprintf (buf, sizeof buf, "%+-#*.20Qe", width, r);<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ((size_t) n &lt; sizeof buf)<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf ("%s\n", buf);<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Prints: +1.41421356237309504880e+00 */<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;quadmath_snprintf (buf, sizeof buf, "%Qa", r);<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ((size_t) n &lt; sizeof buf)<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf ("%s\n", buf);<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Prints: 0x1.6a09e667f3bcc908b2fb1366ea96p+0 */<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;n = quadmath_snprintf (NULL, 0, "%+-#46.*Qe", prec, r);<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (n &gt; -1)<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char *str = malloc (n + 1);<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (str)<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;quadmath_snprintf (str, n + 1, "%+-#46.*Qe", prec, r);<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf ("%s\n", str);<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Prints: +1.41421356237309504880e+00 */<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;free (str);<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 0;<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> &nbsp;On some targets when supported by the C library hooks are installed<br></blockquote><blockquote type="cite">for `printf' family of functions, so that `printf ("%Qe", 1.2Q);' etc.<br></blockquote><blockquote type="cite">works too.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">---<br></blockquote><blockquote type="cite">Fred J. Tydeman &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Tydeman Consulting<br></blockquote><blockquote type="cite"><a href="mailto:tydeman@tybor.com">tydeman@tybor.com</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Testing, numerics, programming<br></blockquote><blockquote type="cite">+1 (775) 358-9748 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vice-chair of PL22.11 (ANSI "C")<br></blockquote><blockquote type="cite">Sample C99+FPCE tests: <a href="http://www.tybor.com">http://www.tybor.com</a><br></blockquote><blockquote type="cite">Savers sleep well, investors eat well, spenders work forever.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">_______________________________________________<br></blockquote><blockquote type="cite">Cfp-interest mailing list<br></blockquote><blockquote type="cite"><a href="mailto:Cfp-interest@oakapple.net">Cfp-interest@oakapple.net</a><br></blockquote><blockquote type="cite"><a href="http://mailman.oakapple.net/mailman/listinfo/cfp-interest">http://mailman.oakapple.net/mailman/listinfo/cfp-interest</a><br></blockquote><br><br>_______________________________________________<br>Cfp-interest mailing list<br><a href="mailto:Cfp-interest@oakapple.net">Cfp-interest@oakapple.net</a><br>http://mailman.oakapple.net/mailman/listinfo/cfp-interest<br></div></blockquote></div><br></div></body></html>