D
Dave
Hello all,
I would like to solicit suggestions on how to most efficiently accomplish
something. I have profiled the project I'm working on and have found that
calls to fabs() are taking a very substantial amount of time. fabs() is
being used in the following manner:
double a, b;
a = get_a_value();
b = get_another_value();
if (fabs(a - b) > 1E-9)
// Do "not equal" stuff
else
// Do "equal" stuff
So, we're simply comparing two doubles for equality and making allowances
for inexact numeric representation.
Of course, we could save time by reducing the number of comparisons. But,
unfortunately, we do need all of the comparisons we're making - none are
redundant or unused. So... Can anybody out there suggest a more efficient
way of accomplishing these comparisons?
Thanks,
Dave
I would like to solicit suggestions on how to most efficiently accomplish
something. I have profiled the project I'm working on and have found that
calls to fabs() are taking a very substantial amount of time. fabs() is
being used in the following manner:
double a, b;
a = get_a_value();
b = get_another_value();
if (fabs(a - b) > 1E-9)
// Do "not equal" stuff
else
// Do "equal" stuff
So, we're simply comparing two doubles for equality and making allowances
for inexact numeric representation.
Of course, we could save time by reducing the number of comparisons. But,
unfortunately, we do need all of the comparisons we're making - none are
redundant or unused. So... Can anybody out there suggest a more efficient
way of accomplishing these comparisons?
Thanks,
Dave