Hello all, I'm trying to round to the 100th with the below macro. Seems to work ok until the value is passed back to main(). Any help would be much appreciated.
float RoundVal(float);
float fault_miles = 0.00;
fault_miles=RoundVal(fault_miles);
float RoundVal(float num)
{
float temp = 0.0;
int i=0;
temp = num;
temp = temp * 100;
temp = temp + 0.50;
i = (int)temp;
printf("%d\n", i);
temp = (i/100.00);
printf("\n%f\n", temp);
return temp;
}
float RoundVal(float);
float fault_miles = 0.00;
fault_miles=RoundVal(fault_miles);
float RoundVal(float num)
{
float temp = 0.0;
int i=0;
temp = num;
temp = temp * 100;
temp = temp + 0.50;
i = (int)temp;
printf("%d\n", i);
temp = (i/100.00);
printf("\n%f\n", temp);
return temp;
}