home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / sharew / f_2_c / libf77 / pow_ri.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-10  |  355 b   |  37 lines

  1. #include "f2c.h"
  2.  
  3. double pow_ri(ap, bp)
  4. real *ap;
  5. integer *bp;
  6. {
  7. double pow, x;
  8. integer n;
  9.  
  10. pow = 1;
  11. x = *ap;
  12. n = *bp;
  13.  
  14. if(n != 0)
  15.     {
  16.     if(n < 0)
  17.         {
  18.         if(x == 0)
  19.             {
  20.             return(pow);
  21.             }
  22.         n = -n;
  23.         x = 1/x;
  24.         }
  25.     for( ; ; )
  26.         {
  27.         if(n & 01)
  28.             pow *= x;
  29.         if(n >>= 1)
  30.             x *= x;
  31.         else
  32.             break;
  33.         }
  34.     }
  35. return(pow);
  36. }
  37.