GRASS Programmer's Manual
6.5.svn(2014)-r66266
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
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
n
int n
Definition:
dataquad.c:291
lib
gmath
max_pow2.c
Generated on Sat Jan 2 2016 01:46:48 for GRASS Programmer's Manual by
1.8.5