I am using the floor function to round the values (round up).
Below is the code, all variables are declared as double
OS: HP-Unix 11
dTemp = dValueToRound * dMultFactor;
printf("dTemp: %f\n", dTemp);
dTemp = floor (dTemp + 0.5);
dRoundedVal = dTemp / dMultFactor;
printf("Rounded value: %f\n", dRoundedVal);
When I try to round the number 1.275 using the above function it is rounding it down to 1.27
If I directly pass the the value 128.00 to the floor function it returns 128.00 but if I do this floor(1.275*100.00 + 0.5) it returns 127.00. I did not understand whether I am missing something.
Help would be appreciated.