<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Here's a second attempt. I'd forgetting the functions that round result to narrower type:<div><br></div><div><div class="WordSection1"><h1><font class="Apple-style-span" size="3"><a name="_Toc188410962"><span lang="EN-GB">16<span> </span>Type-generic math <tgmath.h></span></a><span lang="EN-GB"><o:p></o:p></span></font></h1><p class="MsoNormal"><span lang="EN-GB">The following suggested changes to C11 enhance the specification for type-generic math macros to accommodate functions in Part 1 of this Technical Specification.<o:p></o:p></span></p><p class="MsoNormal"><span lang="EN-GB">Suggested changes to C11:<o:p></o:p></span></p><p class="MsoNormal"><span lang="EN-GB">In 7.25 #2, change:<o:p></o:p></span></p><p class="MsoNormal"><span>For each such function, except <b>modf, </b>there is a corresponding <i>type-generic macro</i><span>.<o:p></o:p></span></span></p><p class="MsoNormal"><span>to:<o:p></o:p></span></p><p class="MsoNormal"><span>For each such function, except <b>modf</b><span>, <b>setpayload</b>, and <b>setpayloadsig</b></span>, there is a corresponding <i>type-generic macro</i><span>.<o:p></o:p></span></span></p><p class="MsoNormal"><span>In 7.25 #3, replace:<o:p></o:p></span></p><p class="MsoNormal"><span>Use of the macro invokes a function whose generic parameters have the corresponding real type determined as follows:<o:p></o:p></span></p><p class="MsoNormal"><span>with:<o:p></o:p></span></p><p class="MsoNormal"><span>Except for the macros for functions that round result to a narrower type (7.12.14), use of the macro invokes a function whose generic parameters have the corresponding real type determined as follows:<o:p></o:p></span></p><p class="MsoNormal"><span>In 7.25 #5, include in the list of type-generic macros: <b>roundeven</b>, <b>nextup</b>, <b>nextdown</b>, <b>fminmag</b>, <b>fmaxmag</b>, <b>llogb</b>, <b>fromfp</b>, <b>ufromfp</b>, <b>fromfpx</b>, <b>ufromfpx</b>, <b>totalorder</b>, <b>totalordermag</b>, and <b>canonicalize</b>.<o:p></o:p></span></p><p class="MsoNormal"><span>After 7.25 #6, add the paragraph:<o:p></o:p></span></p><p class="MsoNormal"><span>The functions that round result to a narrower type have type-generic macros whose names are obtained by omitting any <b>f</b> or <b>l</b> suffix from the function names. Thus, the macros are:<o:p></o:p></span></p></div><b><span style="font-size: 10pt; font-family: Arial; ">[to be in 3 or 4 columns]<br clear="all" style="page-break-before: auto; "></span></b><div class="WordSection2"><p class="MsoNoSpacing" style="margin-left: 20.15pt; "><span>fadd<o:p></o:p></span></p><p class="MsoNoSpacing" style="margin-left: 20.15pt; "><span>dadd<o:p></o:p></span></p><p class="MsoNoSpacing" style="margin-left: 20.15pt; "><span>fsub<o:p></o:p></span></p><p class="MsoNoSpacing" style="margin-left: 20.15pt; "><span>dsub<o:p></o:p></span></p><p class="MsoNoSpacing" style="margin-left: 20.15pt; "><span>fmul<o:p></o:p></span></p><p class="MsoNoSpacing" style="margin-left: 20.15pt; "><span>dmul<o:p></o:p></span></p><p class="MsoNoSpacing" style="margin-left: 20.15pt; "><span>fdiv<o:p></o:p></span></p><p class="MsoNoSpacing" style="margin-left: 20.15pt; "><span>ddiv<o:p></o:p></span></p><p class="MsoNoSpacing" style="margin-left: 20.15pt; "><span>ffma<o:p></o:p></span></p><p class="MsoNoSpacing" style="margin-left: 20.15pt; "><span>dfma<o:p></o:p></span></p><p class="MsoNoSpacing" style="margin-left: 20.15pt; "><span>fsqrt<o:p></o:p></span></p><p class="MsoNoSpacing" style="margin-left: 20.15pt; "><span>dsqrt</span></p></div><p class="MsoNormal"><span>All arguments are generic. If any argument is not real, use of the macro results in undefined behavior. If any argument has type <b>long double</b>, or if the macro prefix is <b>d</b>, the function invoked has the name of the macro with an <b>l</b> suffix. Otherwise, the function invoked has the name of the macro (with no suffix).<o:p></o:p></span></p><p class="MsoNormal"><span>In 7.25 #7, append to the table:<o:p></o:p></span></p><p class="MsoNoSpacing" style="margin-left: 20.15pt; "><span>fsub(f, ld)<span> </span>fsubl(f, ld)<o:p></o:p></span></p><p class="MsoNoSpacing" style="margin-left: 20.15pt; "><span>fdiv(d, n)<span> </span>fdiv(d, n)</span><span style="font-weight: normal; ">, the function</span><span><o:p></o:p></span></p><p class="MsoNoSpacing" style="margin-left: 20.15pt; "><span>dfma(f, d, ld)<span> </span>dfmal(f, d, ld)<o:p></o:p></span></p><p class="MsoNoSpacing" style="margin-left: 20.15pt; "><span>dadd(f, f)<span> </span>daddl(f, f)<o:p></o:p></span></p><p class="MsoNoSpacing" style="margin-left: 20.15pt; "><span>dsqrt(dc)<span> </span></span><span style="font-weight: normal; ">undefined behavior</span></p><div>-Jim</div><div><br></div><div><div>On Jan 17, 2012, at 2:13 PM, Jim Thomas wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hmm. The Functions document excludes them but doesn't say why. Does anyone remember? If not, I'll include them for now.<br><br>The issue Joel raised is about the difficulty in using the new _Generic mechanism to implement type-generic macros with more than one generic argument. This may be an issue for _Generic, but not for making such functions type-generic. As Fred pointed out, we already have 2 and 3 argument type-generic functions (which have been implemented, though, to my knowledge, without using _Generic).<br><br>-Jim<br><br>On Jan 17, 2012, at 10:58 AM, Fred J. Tydeman wrote:<br><br><blockquote type="cite">On Tue, 17 Jan 2012 10:13:37 -0800 Jim Thomas wrote:<br></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">and the total order functions (F.10.12)<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Why are they excluded?<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">---<br></blockquote><blockquote type="cite">Fred J. Tydeman Tydeman Consulting<br></blockquote><blockquote type="cite"><a href="mailto:tydeman@tybor.com">tydeman@tybor.com</a> Testing, numerics, programming<br></blockquote><blockquote type="cite">+1 (775) 358-9748 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><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>