oprecomp/flexfloat

No sqrt, fabs?

Closed this issue · 2 comments

Hi there,

I'm using FlexFloat with some numerical kernels that come from finite element calculations.

Mostly I can just replace double with flexfloat<11, 16> or whatever, and compile... this is great! I have a couple of annoyances, though. Firstly, sqrt and fabs don't seem to be supported by the flexfloat type. I.e. I have to manually add a cast to e.g. sqrt(a*b + c) to become sqrt(double(a*b + c)), and similarly with fabs. Am I doing something wrong, or are these operations not supported yet?

Secondly, a statement of the form double = double + flexfloat doesn't seem to work... I have to again add a manual cast double = double + double(flexfloat). Is this expected?

Hi Andrew,

Thank you very much for your feedback!

  1. A math library based on FlexFloat is not available yet. At the time being, the fastest alternative is using the standard C math library as you are doing, which requires explicit casts to the primitive types.

  2. Yes, an explicit cast is expected to guarantee strict type checks. If you try to remove the "explicit" keyword in the method "operator double()" to loosen this constraint, you can see that this change would introduce several ambiguities in operator overloading.

Alright, thanks for the response!