-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommon.c
37 lines (28 loc) · 808 Bytes
/
common.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "common.h"
#include <assert.h>
#include <stdlib.h>
integer Log2(integer r)
{
integer temp=0;
r >>= 1;
while(r > 0)
{
r >>= 1;
temp++;
}
return temp;
}
//////////////////////////////////////////////////////////////////////////////
int is_pow_of_2( integer r )
{
return ( ((r>>Log2(r))<<Log2(r)) == r );
}
///////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// M O D U L O 3 6 0
//////////////////////////////////////////////////////////////////////////////
double MOD360(double a)
{
//printf("a%lf mod%lf",a,(((a+360.)/360.) - ( (int) ((a+360.)/360.) ) ) * 360.);
return (((a+360.)/360.) - ( (int) ((a+360.)/360.) ) ) * 360.;
}