[Cfp-interest] FUNCTIONS first attempt at defining calling sequences for reduction operations

David Hough CFP pcfp at oakapple.net
Wed May 19 17:23:58 PDT 2010


> The question remains of what the type of the scale factor for the scaled functions is.  "int" may not suffice, as it is easily overflowed for reasonable sized vectors, even on a 32-bit machine[*].  As I see it, the "desirable" constraints on the type of the scale factor are:
> 
>     1. it should be a signed integer type
>     2. unscaling can easily be done using library functions.
>     3. it should be wide enough to make overflow unlikely, when possible
> 
> To my mind, this points to "long" as the type for the scale factor.  Rescaling can be done with scalbln( ), which was standardized in C99.

I think that's a reasonable argument.    754 can't assume that there is more
than one integer type, but integer types abound in C.

> One detail is that to stick strictly to the 754 behavior, if you overflow scale, you can't just return NaN; you need to continue processing the inputs to ensure that there is no infinity lurking that would force you to return inf instead.

I think you might get infinity and zero and zero * inf for no extra cost;
in the normal case you keep track automatically as you accumulate the
scaled product.    If the abnormal case costs as much as the normal case,
that's no great loss.     You can't short-circuit the normal case for
zero and inf because the other might appear at the end.




More information about the Cfp-interest mailing list