Hello, I have created a rounding function, and i need help implementing it on a row of data that I have.
1 2 3 4 5 6 7 8 9 10 11
float round_value(float value, int decimal_places)
{
int magnitude = 1;
for (int i = 0; i = decimal_places; i++) {
magnitude = magnitude * 10;
}
value = value * magnitude;
value = int (value + .5);
value = value / magnitude;
return value;
}
I tried this just after it, but it doesn't work, I thought it would take the value in the row, apply the rounding function then put it back into there.
What you've shown in the third snippet looks like it should work assuming your round_value function is correct and that rowAverage is declared as: float rowAverage[MAX_ROWS];
You need to show more of your code.
Have you displayed the before and after values to see what you're getting?