MOM6
bitcount.c
Go to the documentation of this file.
1 #include <stddef.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <math.h>
6 /* bitcount : count 1 bits in x */
7 int bitcount_(double *x)
8 {
9 int b;
10 unsigned long *y;
11 double z;
12 
13 z = *x;
14 y = (unsigned long *) &z;
15 for (b = 0; *y !=0; *y >>= 1)
16  if (*y & 01)
17  b++;
18 return b;
19 }
20 
21 /* wrapper for IBM system */
22 int bitcount(double *x)
23 {
24  return bitcount_(x);
25 }
int bitcount_(double *x)
Definition: bitcount.c:7
int bitcount(double *x)
Definition: bitcount.c:22