repo.or.cz
/
WRF.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
updated top-level README and version_decl for V4.4.2 (#1795)
[WRF.git]
/
external
/
io_grib1
/
WGRIB
/
intpower.c
blob
43112ed18d07e4b217cfc1a1c4d56ab5ce1a851d
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
}