I am working on the problem of high-speed computing for large-scale modeling. To speed up the process, I want to make a couple of optimizations, one of which is to calculate the absolute value of the double in just a couple of cycles without transitions.
My idea was that 64-bit binary values ββare represented by a 1-bit bit, an 11-bit metric, and a 52-bit Mantissa. So, the double value of XOR-ed with mask: 10000000000000000000000000000000 will give the desired result:
double abs(double x) {
double mask = -0.0e0;
return x^mask;
}
Now, obviously, there are few reasons why double operations in doubles are needed, therefore, of course, the compiler throws an error:
error: invalid operands to binary ^ (have βdoubleβ and βdoubleβ)
I was wondering if there is a way to quickly make this work, since I did not want to convert all this to a char -array and vice versa, as suggested elsewhere. This can undermine the goal of quick calculation.
I am grateful for the help ...
source
share