~ubuntu-branches/ubuntu/trusty/libf2c2/trusty

« back to all changes in this revision

Viewing changes to libF77/pow_ri.c

  • Committer: Bazaar Package Importer
  • Author(s): Alan Bain
  • Date: 2008-05-19 22:50:54 UTC
  • mfrom: (2.1.4 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080519225054-jlymia0wdvvfq7dg
Tags: 20061008-4
Remove CVS directory left in source package

Show diffs side-by-side

added added

removed removed

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