Are these constants a to j well known names in the literature?
Code:
float calc_abv(float abw)
{
float abv = 0;
float a = -0.000039705486746795932;
float b = 1.2709666849144778;
float c = -0.40926819348115739;
float d = 2.0463351302912738;
float f = -7.8964816507513707;
float g = 15.009692673927390;
float h = -15.765836469736477;
float i = 8.8142267038252680;
float j = -2.0695760421183493;
float temp = j;
temp = temp * abw +i;
temp = temp * abw +h;
temp = temp * abw +g;
temp = temp * abw +f;
temp = temp * abw +d;
temp = temp * abw +c;
temp = temp * abw +b;
abv = temp * abw +a;
return (abv);
}
If they are, keeping them is okay, though you might want to place a comment with some explanation. If they are not, then you're just naming constants for the sake of naming them without providing descriptive names, so there's no point. I would prefer to use a static array and a loop instead:
Code:
float calc_abv(float abw)
{
static const float modifiers[] = {
-2.0695760421183493,
8.8142267038252680,
-15.765836469736477,
15.009692673927390,
-7.8964816507513707,
2.0463351302912738,
-0.40926819348115739,
1.2709666849144778,
-0.000039705486746795932
};
float abv = 0.0f;
for (size_t i = 0; i < sizeof(modifiers) / sizeof(modifiers[0]); ++i)
{
abv = abv * abw + modifiers[i];
}
return abv;
}
Then again, even if the constants a to j are well known names in the literature, you might use this array+loop approach anyway and just write the domain-specific constant names as comments next to the array elements.