Last change
on this file since 1 was
1,
checked in by lfita, 10 years ago
|
- -- --- Opening of the WRF+LMDZ coupling repository --- -- -
WRF: version v3.3
LMDZ: version v1818
More details in:
|
File size:
321 bytes
|
Line | |
---|
1 | #include <stdio.h> |
---|
2 | #include <stdlib.h> |
---|
3 | |
---|
4 | /* |
---|
5 | * w. ebisuzaki |
---|
6 | * |
---|
7 | * return x**y |
---|
8 | * |
---|
9 | * |
---|
10 | * input: double x |
---|
11 | * int y |
---|
12 | */ |
---|
13 | double int_power(double x, int y) { |
---|
14 | |
---|
15 | double value; |
---|
16 | |
---|
17 | if (y < 0) { |
---|
18 | y = -y; |
---|
19 | x = 1.0 / x; |
---|
20 | } |
---|
21 | value = 1.0; |
---|
22 | |
---|
23 | while (y) { |
---|
24 | if (y & 1) { |
---|
25 | value *= x; |
---|
26 | } |
---|
27 | x = x * x; |
---|
28 | y >>= 1; |
---|
29 | } |
---|
30 | return value; |
---|
31 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.