f2clib.c
上传用户:zslianheng
上传日期:2013-04-03
资源大小:946k
文件大小:1k
源码类别:

Linux/Unix编程

开发平台:

Visual C++

  1. /*
  2. $Log: f2clib.c,v $
  3. Revision 1.1.1.1  2002/07/28 05:23:47  freeman_yong
  4. lpc10 codec
  5.  * Revision 1.1  1996/08/19  22:32:10  jaf
  6.  * Initial revision
  7.  *
  8. */
  9. /*
  10.  * f2clib.c
  11.  *
  12.  * SCCS ID:  @(#)f2clib.c 1.2 96/05/19
  13.  */
  14. #include "f2c.h"
  15. #ifdef KR_headers
  16. integer pow_ii(ap, bp) integer *ap, *bp;
  17. #else
  18. integer pow_ii(integer *ap, integer *bp)
  19. #endif
  20. {
  21. integer pow, x, n;
  22. unsigned long u;
  23. x = *ap;
  24. n = *bp;
  25. if (n <= 0) {
  26. if (n == 0 || x == 1)
  27. return 1;
  28. if (x != -1)
  29. return x == 0 ? 1/x : 0;
  30. n = -n;
  31. }
  32. u = n;
  33. for(pow = 1; ; )
  34. {
  35. if(u & 01)
  36. pow *= x;
  37. if(u >>= 1)
  38. x *= x;
  39. else
  40. break;
  41. }
  42. return(pow);
  43. }
  44. #ifdef KR_headers
  45. double r_sign(a,b) real *a, *b;
  46. #else
  47. double r_sign(real *a, real *b)
  48. #endif
  49. {
  50. double x;
  51. x = (*a >= 0 ? *a : - *a);
  52. return( *b >= 0 ? x : -x);
  53. }
  54. #ifdef KR_headers
  55. double floor();
  56. integer i_nint(x) real *x;
  57. #else
  58. #undef abs
  59. #include "math.h"
  60. integer i_nint(real *x)
  61. #endif
  62. {
  63. return( (*x)>=0 ?
  64. floor(*x + .5) : -floor(.5 - *x) );
  65. }