source: tags/4.1.0/c_bits.sh

Last change on this file was 1, checked in by katerina, 15 years ago

Initial import

File size: 2.2 KB
Line 
1#! /bin/sh
2
3
4# get bits of $1
5
6# make sure it fits in 16 bit
7ORIG=`expr $1 \% 65536`
8
9# 1 2 3 4  5  6  7   8   9  10   11   12   13   14    15    16
10# 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768
11
12N=0
13
14N=`expr $ORIG \/ 32768`
15N_16=$N
16if test "x$N" = "x1"; then
17  echo "#define $2_16 1"
18fi
19ORIG=`expr $ORIG \- $N_16 \* 32768`
20
21N=`expr $ORIG / 16384`
22N_15=$N
23if test "x$N" = "x1"; then
24  echo "#define $2_15 1"
25fi
26ORIG=`expr $ORIG \- $N_15 \* 16384`
27
28N=`expr $ORIG \/ 8192`
29N_14=$N
30if test "x$N" = "x1"; then
31  echo "#define $2_14 1"
32fi
33ORIG=`expr $ORIG \- $N_14 \* 8192`
34
35N=`expr $ORIG \/ 4096`
36N_13=$N
37if test "x$N" = "x1"; then
38  echo "#define $2_13 1"
39fi
40ORIG=`expr $ORIG \- $N_13 \* 4096`
41
42N=`expr $ORIG \/ 2048`
43N_12=$N
44if test "x$N" = "x1"; then
45  echo "#define $2_12 1"
46fi
47ORIG=`expr $ORIG \- $N_12 \* 2048`
48
49N=`expr $ORIG \/ 1024`
50N_11=$N
51if test "x$N" = "x1"; then
52  echo "#define $2_11 1"
53fi
54ORIG=`expr $ORIG \- $N_11 \* 1024`
55
56N=`expr $ORIG \/ 512`
57N_10=$N
58if test "x$N" = "x1"; then
59  echo "#define $2_10 1"
60fi
61ORIG=`expr $ORIG \- $N_10 \* 512`
62
63N=`expr $ORIG \/ 256`
64N_09=$N
65if test "x$N" = "x1"; then
66  echo "#define $2_09 1"
67fi
68ORIG=`expr $ORIG \- $N_09 \* 256`
69
70N=`expr $ORIG \/ 128`
71N_08=$N
72if test "x$N" = "x1"; then
73  echo "#define $2_08 1"
74fi
75ORIG=`expr $ORIG \- $N_08 \* 128`
76
77N=`expr $ORIG \/ 64`
78N_07=$N
79if test "x$N" = "x1"; then
80  echo "#define $2_07 1"
81fi
82ORIG=`expr $ORIG \- $N_07 \* 64`
83
84N=`expr $ORIG \/ 32`
85N_06=$N
86if test "x$N" = "x1"; then
87  echo "#define $2_06 1"
88fi
89ORIG=`expr $ORIG \- $N_06 \* 32`
90
91N=`expr $ORIG \/ 16`
92N_05=$N
93if test "x$N" = "x1"; then
94  echo "#define $2_05 1"
95fi
96ORIG=`expr $ORIG \- $N_05 \* 16`
97
98N=`expr $ORIG \/ 8`
99N_04=$N
100if test "x$N" = "x1"; then
101  echo "#define $2_04 1"
102fi
103ORIG=`expr $ORIG \- $N_04 \* 8`
104
105N=`expr $ORIG \/ 4`
106N_03=$N
107if test "x$N" = "x1"; then
108  echo "#define $2_03 1"
109fi
110ORIG=`expr $ORIG \- $N_03 \* 4`
111
112N=`expr $ORIG \/ 2`
113N_02=$N
114if test "x$N" = "x1"; then
115  echo "#define $2_02 1"
116fi
117ORIG=`expr $ORIG \- $N_02 \* 2`
118
119N=`expr $ORIG \/ 1`
120N_01=$N
121if test "x$N" = "x1"; then
122  echo "#define $2_01 1"
123fi
124ORIG=`expr $ORIG \- $N_01 \* 1`
125
126#
127# obsolete
128#
129# echo ${N_01} ${N_02} ${N_03} ${N_04} ${N_05} ${N_06} ${N_07} ${N_08} ${N_09} ${N_10}  ${N_11} ${N_12}  ${N_13} ${N_14} ${N_15} ${N_16}
130
131exit   0
132
133
Note: See TracBrowser for help on using the repository browser.