GRASS GIS 7 Programmer's Manual
7.0.3(2016)-r00000
Main Page
Related Pages
Data Structures
Files
File List
Globals
max_pow2.c
Go to the documentation of this file.
1
#include <grass/gis.h>
2
#include <grass/gmath.h>
3
4
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
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
}
G_math_max_pow2
long G_math_max_pow2(const long n)
Finds least power of 2 >= n
Definition:
max_pow2.c:16
G_math_min_pow2
long G_math_min_pow2(const long n)
Finds largest power of 2 <= n
Definition:
max_pow2.c:44
gmath
max_pow2.c
Generated on Tue Apr 5 2016 12:25:31 for GRASS GIS 7 Programmer's Manual by
1.8.11