AFAIK int() rounds towards zero. I need a function that rounds towards
-inf. It is used heavily in sampling from and reconstructing images,
which is the main bottleneck in many of our applications.
I've know about the pipeline problem, but have never been fully
convinced that there isn't another way, especially since all the
discussion of the pipeline problem focuses on int() rather than my function.
Amitha Perera wrote:
> Ian Scott wrote:
>> BTW: Does anyone know of a fast implementation of
>> int vnl_math_floor(double x);
> Isn't that called "int()"? From my limited knowledge, there is no fast
> way to do it. You could set the floating point rounding flags to round
> to -ve inf, and then use the rounding functions. Apparently this is the
> code that gcc emits for "int()", with additional code to restore the
> flags afterward. Apparently setting and restoring the flags is the slow
> part, because it flushes the FP pipeline.