Quick rounding routine that will fix the floating point flaw when trying to display a value on a form.
double To_Int(double Value)
{
double Lower, Upper, LDiff, UDiff, NewVal;
long int TempVal;
double ReturnVal;
NewVal = Value*10000;
Lower = floor(NewVal);
Upper = ceil(NewVal);
LDiff = NewVal - Lower;
UDiff = Upper - NewVal;
if (LDiff < UDiff)
TempVal = (long int) Lower;
else
TempVal = (long int) Upper;
ReturnVal = (double) TempVal/10000;
return ReturnVal; // Extend 4 decimal places
}