GRASS GIS 7 Programmer's Manual
7.9.dev(2021)-e5379bbd7
Main Page
Related Pages
+
Data Structures
Data Structures
Class Hierarchy
+
Data Fields
+
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
~
+
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Related Functions
+
Files
File List
+
Globals
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Variables
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
w
x
y
+
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
o
p
r
s
t
u
v
w
y
z
+
Enumerations
a
c
d
e
h
l
m
n
o
p
r
s
t
v
y
+
Enumerator
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
+
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
•
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
max_pow2.c
Go to the documentation of this file.
1
#include <
grass/gis.h
>
2
#include <
grass/gmath.h
>
3
4
5
/*!
6
* \fn long G_math_max_pow2 (const long n)
7
*
8
* \brief Finds least power of 2 >= <b>n</b>
9
*
10
* Finds least power of 2 >= <b>n</b>.
11
*
12
* \param[in] n
13
* \return long
14
*/
15
16
long
G_math_max_pow2
(
const
long
n)
17
{
18
long
p2, n1;
19
20
n1 = n >> 1;
21
p2 = 1;
22
while
(n1 > 0) {
23
n1 >>= 1;
24
p2 <<= 1;
25
}
26
if
(p2 < n)
27
p2 <<= 1;
28
29
return
(p2);
30
}
31
32
33
/*!
34
* \fn long G_math_min_pow2 (const long n)
35
*
36
* \brief Finds largest power of 2 <= <b>n</b>
37
*
38
* Finds largest power of 2 <= <b>n</b>.
39
*
40
* \param[in] n
41
* \return long
42
*/
43
44
long
G_math_min_pow2
(
const
long
n)
45
{
46
long
p2, n1;
47
48
n1 = n >> 1;
49
p2 = 1;
50
while
(n1 > 0) {
51
n1 >>= 1;
52
p2 <<= 1;
53
}
54
55
return
(p2);
56
}
gmath.h
G_math_max_pow2
long G_math_max_pow2(const long n)
Finds least power of 2 >= n
Definition:
max_pow2.c:16
gis.h
G_math_min_pow2
long G_math_min_pow2(const long n)
Finds largest power of 2 <= n
Definition:
max_pow2.c:44
lib
gmath
max_pow2.c
Generated on Mon May 31 2021 05:21:30 for GRASS GIS 7 Programmer's Manual by
1.8.13