[Cfp-interest] type-generic math
Joel C. Salomon
joelcsalomon at gmail.com
Thu Jan 19 05:24:14 PST 2012
On 01/18/2012 08:30 PM, Jim Thomas wrote:
> Here's a second attempt. I'd forgetting the functions that round result
> to narrower type:
>
> 16 Type-generic math <tgmath.h>
<snip>
> 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.
Are you satisfied with a call to totalorder with different types being
defined; e.g., `totalorder(1.0f, 2.0) => totalorder((double)1.0f, 2.0)`?
Note that without totalorder being type-generic, the functions *can* be
protected against mixed use:
#define __totalorder(x, y, type, func) \
(_Generic(x, type: _Generic(y, type: func))(x, y))
#define totalorder(x, y) __totalorder((x), (y), double, totalorder)
#define totalorderf(x, y) __totalorder((x), (y), float, totalorderf)
...
--Joel
More information about the Cfp-interest
mailing list