Last change
on this file was
2759,
checked in by aslmd, 2 years ago
|
adding unmodified code from WRFV3.0.1.1, expurged from useless data +1M size
|
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.