home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 1 / FishNMoreVol1.bin / more / code_examples / librar / dround.c < prev    next >
Text File  |  1989-02-08  |  660b  |  29 lines

  1. /*--------------------------------------*/
  2. /*                    */
  3. /*              DROUND(X,X)        */
  4. /*                    */
  5. /* Rounds a floating point number. The  */
  6. /* first argument is the number to be   */
  7. /* rounded. The second argument is the  */
  8. /* decimal precision to be rounded to.  */
  9. /*                    */
  10. /*--------------------------------------*/
  11. double dround(floter,b)
  12. int b;
  13. double floter;
  14. {
  15.         float ff;
  16.         double ii,iii,pow(),h,hh;
  17.         long a,d;
  18.         a=floter;
  19.         ii=floter-a;
  20.         h=10;
  21.         hh=b;
  22.         hh=pow(h,hh);
  23.         ff=ii=ii*hh;
  24.         d=round(ff);
  25.         ii=1/hh;
  26.         iii=a+(d*ii);
  27.         return(iii);
  28. }
  29.