[Cfp-interest] type-generic math

Jim Thomas jaswthomas at sbcglobal.net
Wed Jan 18 17:30:06 PST 2012


Here's a second attempt. I'd forgetting the functions that round result to narrower type:

16  Type-generic math <tgmath.h>

The following suggested changes to C11 enhance the specification for type-generic math macros to accommodate functions in Part 1 of this Technical Specification.

Suggested changes to C11:

In 7.25 #2, change:

For each such function, except modf, there is a corresponding type-generic macro.

to:

For each such function, except modf, setpayload, and setpayloadsig, there is a corresponding type-generic macro.

In 7.25 #3, replace:

Use of the macro invokes a function whose generic parameters have the corresponding real type determined as follows:

with:

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:

In 7.25 #5, include in the list of type-generic macros: roundeven, nextup, nextdown, fminmag, fmaxmag, llogb, fromfp, ufromfp, fromfpx, ufromfpx, totalorder, totalordermag, and canonicalize.

After 7.25 #6, add the paragraph:

The functions that round result to a narrower type have type-generic macros whose names are obtained by omitting any f or l suffix from the function names. Thus, the macros are:

[to be in 3 or 4 columns]
fadd

dadd

fsub

dsub

fmul

dmul

fdiv

ddiv

ffma

dfma

fsqrt

dsqrt

All arguments are generic. If any argument is not real, use of the macro results in undefined behavior. If any argument has type long double, or if the macro prefix is d, the function invoked has the name of the macro with an l suffix. Otherwise, the function invoked has the name of the macro (with no suffix).

In 7.25 #7, append to the table:

fsub(f, ld)              fsubl(f, ld)

fdiv(d, n)               fdiv(d, n), the function

dfma(f, d, ld)        dfmal(f, d, ld)

dadd(f, f)               daddl(f, f)

dsqrt(dc)               undefined behavior

-Jim

On Jan 17, 2012, at 2:13 PM, Jim Thomas wrote:

> Hmm. The Functions document excludes them but doesn't say why. Does anyone remember? If not, I'll include them for now.
> 
> 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).
> 
> -Jim
> 
> On Jan 17, 2012, at 10:58 AM, Fred J. Tydeman wrote:
> 
>> On Tue, 17 Jan 2012 10:13:37 -0800 Jim Thomas wrote:
>>> 
>>> and the total order functions (F.10.12)
>> 
>> Why are they excluded?
>> 
>> 
>> ---
>> Fred J. Tydeman        Tydeman Consulting
>> tydeman at tybor.com      Testing, numerics, programming
>> +1 (775) 358-9748      Vice-chair of PL22.11 (ANSI "C")
>> Sample C99+FPCE tests: http://www.tybor.com
>> Savers sleep well, investors eat well, spenders work forever.
> 
> 
> _______________________________________________
> Cfp-interest mailing list
> Cfp-interest at oakapple.net
> http://mailman.oakapple.net/mailman/listinfo/cfp-interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20120118/dd2accff/attachment.html 


More information about the Cfp-interest mailing list