Listing 1 A rounding algorithm that could stand improvement

#include <math.h>
extern double round_cent (double);

#define SMALLNUM .00000000001 /*super small number (100's)*/
       /*(smallnum is added to a double before truncating to an integer
         to ensure that a number like 5.99999999999999999 is really 6.0)
        */

double round_cent (num)
/*     round_cent rounds a number to the cents place (round to .01).*/
double num; /*number to round*/
{

      double tdoub; /*temporary double*/
      
      tdoub = num * 100.0 + .5 + SMALLNUM; /*move num to left
                                      and add .50000000001 for rounding*/
      tdoub = floor (tdoub); /*drop decimals*/
      return (tdoub * .01); /*move num back to right*/
}

/* End of File */