source: tests/bitmanip3.cfa @ 6c4bd02

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 6c4bd02 was a3fab47, checked in by Peter A. Buhr <pabuhr@…>, 5 years ago

fix infinite-loop build error for bitmanip3, changing from adds to shifts

  • Property mode set to 100644
File size: 23.7 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2020 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// bitmanip3.cfa --
8//
9// Author           : Peter A. Buhr
10// Created On       : Tue Apr  7 21:22:59 2020
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Tue Apr 21 16:25:09 2020
13// Update Count     : 61
14//
15
16#include <fstream.hfa>
17#include <bitmanip.hfa>
18
19int main() {
20        bool b1, b2;
21        signed char sc, scr1, scr2, scr3;
22        unsigned char uc, ucr1, ucr2, ucr3;
23        short int si, sir1, sir2, sir3;
24        unsigned short int usi, usir1, usir2, usir3;
25        int i, ir1, ir2, ir3;
26        unsigned int ui, uir1, uir2, uir3;
27        long int li, lir1, lir2, lir3;
28        unsigned long int uli, ulir1, ulir2, ulir3;
29        long long int lli, llir1, llir2, llir3;
30        unsigned long long int ulli, ullir1, ullir2, ullir3;
31
32        //============================================================
33#if 1
34        sout | nl | "is_pow2" | nl | nl;
35
36        sout | "signed char";
37        sc = 0;
38        b1 = is_pow2( sc ), b2 = is_pow2( sc + 13hh );
39        sout | wd(__bitsizeof(sc)+2, pad0(bin(sc))) | b1 | wd(__bitsizeof(sc)+2, pad0(bin(sc + 13hh))) | b2;
40        for ( sc = 1; sc != 0; sc <<= 1 ) {
41                b1 = is_pow2( sc ), b2 = is_pow2( sc + 13hh );
42                sout | wd(__bitsizeof(sc)+2, pad0(bin(sc))) | b1 | wd(__bitsizeof(sc)+2, pad0(bin(sc + 13hh))) | b2;
43        } // for
44        sout | nl;
45        sout | "unsigned char";
46        uc = 0;
47        b1 = is_pow2( uc ), b2 = is_pow2( uc + 13hh );
48        sout | wd(__bitsizeof(uc)+2, pad0(bin(uc))) | b1 | wd(__bitsizeof(uc)+2, pad0(bin(uc + 13hh))) | b2;
49        for ( uc = 1; uc != 0; uc <<= 1 ) {
50                b1 = is_pow2( uc ), b2 = is_pow2( uc + 13hh );
51                sout | wd(__bitsizeof(uc)+2, pad0(bin(uc))) | b1 | wd(__bitsizeof(uc)+2, pad0(bin(uc + 13hh))) | b2;
52        } // for
53        sout | nl;
54
55        sout | "short int";
56        si = 0;
57        b1 = is_pow2( si ), b2 = is_pow2( si + 13hh );
58        sout | wd(__bitsizeof(si)+2, pad0(bin(si))) | b1 | wd(__bitsizeof(si)+2, pad0(bin(si + 13h))) | b2;
59        for ( si = 1; si != 0; si <<= 1 ) {
60                b1 = is_pow2( si ), b2 = is_pow2( si + 13hh );
61                sout | wd(__bitsizeof(si)+2, pad0(bin(si))) | b1 | wd(__bitsizeof(si)+2, pad0(bin(si + 13h))) | b2;
62        } // for
63        sout | nl;
64        sout | "unsigned short int";
65        usi = 0;
66        b1 = is_pow2( usi ), b2 = is_pow2( usi + 13hh );
67        sout | wd(__bitsizeof(usi)+2, pad0(bin(usi))) | b1 | wd(__bitsizeof(usi)+2, pad0(bin(usi + 13hh))) | b2;
68        for ( usi = 1; usi != 0; usi <<= 1 ) {
69                b1 = is_pow2( usi ), b2 = is_pow2( usi + 13hh );
70                sout | wd(__bitsizeof(usi)+2, pad0(bin(usi))) | b1 | wd(__bitsizeof(usi)+2, pad0(bin(usi + 13hh))) | b2;
71        } // for
72        sout | nl;
73
74        sout | "int";
75        i = 0;
76        b1 = is_pow2( i ), b2 = is_pow2( i + 13hh );
77        sout | wd(__bitsizeof(i)+2, pad0(bin(i))) | b1 | wd(__bitsizeof(i)+2, pad0(bin(i + 13h))) | b2;
78        for ( i = 1; i != 0; i <<= 1 ) {
79                b1 = is_pow2( i ), b2 = is_pow2( i + 13hh );
80                sout | wd(__bitsizeof(i)+2, pad0(bin(i))) | b1 | wd(__bitsizeof(i)+2, pad0(bin(i + 13h))) | b2;
81        } // for
82        sout | nl;
83        sout | "unsigned int";
84        ui = 0;
85        b1 = is_pow2( ui ), b2 = is_pow2( ui + 13hh );
86        sout | wd(__bitsizeof(ui)+2, pad0(bin(ui))) | b1 | wd(__bitsizeof(ui)+2, pad0(bin(ui + 13hh))) | b2;
87        for ( ui = 1; ui != 0; ui <<= 1 ) {
88                b1 = is_pow2( ui ), b2 = is_pow2( ui + 13hh );
89                sout | wd(__bitsizeof(ui)+2, pad0(bin(ui))) | b1 | wd(__bitsizeof(ui)+2, pad0(bin(ui + 13hh))) | b2;
90        } // for
91        sout | nl;
92
93        sout | "long int";
94        li = 0;
95        b1 = is_pow2( li ), b2 = is_pow2( li + 13hh );
96        sout | wd(__bitsizeof(li)+2, pad0(bin(li))) | b1 | wd(__bitsizeof(li)+2, pad0(bin(li + 13h))) | b2;
97        for ( li = 1; li != 0; li <<= 1 ) {
98                b1 = is_pow2( li ), b2 = is_pow2( li + 13hh );
99                sout | wd(__bitsizeof(li)+2, pad0(bin(li))) | b1 | wd(__bitsizeof(li)+2, pad0(bin(li + 13h))) | b2;
100        } // for
101        sout | nl;
102        sout | "unsigned long int";
103        uli = 0;
104        b1 = is_pow2( uli ), b2 = is_pow2( uli + 13hh );
105        sout | wd(__bitsizeof(uli)+2, pad0(bin(uli))) | b1 | wd(__bitsizeof(uli)+2, pad0(bin(uli + 13h))) | b2;
106        for ( uli = 1; uli != 0; uli <<= 1 ) {
107                b1 = is_pow2( uli ), b2 = is_pow2( uli + 13hh );
108                sout | wd(__bitsizeof(uli)+2, pad0(bin(uli))) | b1 | wd(__bitsizeof(uli)+2, pad0(bin(uli + 13h))) | b2;
109        } // for
110        sout | nl;
111
112        sout | "long long int";
113        lli = 0;
114        b1 = is_pow2( lli ), b2 = is_pow2( lli + 13hh );
115        sout | wd(__bitsizeof(lli)+2, pad0(bin(lli))) | b1 | wd(__bitsizeof(lli)+2, pad0(bin(lli + 13h))) | b2;
116        for ( lli = 1; lli != 0; lli <<= 1 ) {
117                b1 = is_pow2( lli ), b2 = is_pow2( lli + 13hh );
118                sout | wd(__bitsizeof(lli)+2, pad0(bin(lli))) | b1 | wd(__bitsizeof(lli)+2, pad0(bin(lli + 13h))) | b2;
119        } // for
120        sout | nl;
121        sout | "unsigned long long int";
122        ulli = 0;
123        b1 = is_pow2( ulli ), b2 = is_pow2( ulli + 13hh );
124        sout | wd(__bitsizeof(ulli)+2, pad0(bin(ulli))) | b1 | wd(__bitsizeof(ulli)+2, pad0(bin(ulli + 13h))) | b2;
125        for ( ulli = 1; ulli != 0; ulli <<= 1 ) {
126                b1 = is_pow2( ulli ), b2 = is_pow2( ulli + 13hh );
127                sout | wd(__bitsizeof(ulli)+2, pad0(bin(ulli))) | b1 | wd(__bitsizeof(ulli)+2, pad0(bin(ulli + 13h))) | b2;
128        } // for
129        sout | nl;
130#endif // 0
131        //============================================================
132#if 1
133        sout | nl | "floor2" | nl | nl;
134
135        printf( "signed char\n" );
136        sc = 0;
137        scr1 = floor2( sc, sc ), scr2 = floor2( sc + 2hh, sc ), scr3 = floor2( -sc - 2hh, sc );
138        printf( "floor2(%hhd, %hhd) = %hhd, floor2(%hhd, %hhd) = %hhd, floor2(%hhd, %hhd) = %hhd\n", sc, sc, scr1, sc + 2hh, sc, scr2, -sc - 2hh, sc, scr3 );
139        for ( sc = 1; sc != 0; sc <<= 1 ) {
140                scr1 = floor2( sc, sc ); scr2 = floor2( sc + 2hh, sc ); scr3 = floor2( -sc - 2hh, sc );
141                printf( "floor2(%hhd, %hhd) = %hhd, floor2(%hhd, %hhd) = %hhd, floor2(%hhd, %hhd) = %hhd\n", sc, sc, scr1, sc + 2hh, sc, scr2, -sc - 2hh, sc, scr3 );
142        } // for
143        printf( "\n" );
144
145        printf( "unsigned char\n" );
146        uc = 0;
147        ucr1 = floor2( uc, uc ), ucr2 = floor2( uc + 2hh, uc ), ucr3 = floor2( -uc - 2hh, uc );
148        printf( "floor2(%hhu, %hhu) = %hhu, floor2(%hhu, %hhu) = %hhu, floor2(%hhu, %hhu) = %hhu\n", uc, uc, ucr1, uc + 2uhh, uc, ucr2, -uc - 2uhh, uc, ucr3 );
149        for ( uc = 1; uc != 0; uc <<= 1 ) {
150                ucr1 = floor2( uc, uc ); ucr2 = floor2( uc + 2hh, uc ); ucr3 = floor2( -uc - 2hh, uc );
151                printf( "floor2(%hhu, %hhu) = %hhu, floor2(%hhu, %hhu) = %hhu, floor2(%hhu, %hhu) = %hhu\n", uc, uc, ucr1, uc + 2uhh, uc, ucr2, -uc - 2uhh, uc, ucr3 );
152        } // for
153        printf( "\n" );
154
155        printf( "short int\n" );
156        si = 0;
157        sir1 = floor2( si, si ), sir2 = floor2( si + 2hh, si ), sir3 = floor2( -si - 2hh, si );
158        printf( "floor2(%hd, %hd) = %hd, floor2(%hd, %hd) = %hd, floor2(%hd, %hd) = %hd\n", si, si, sir1, si + 2h, si, sir2, -si - 2h, si, sir3 );
159        for ( si = 1; si != 0; si <<= 1 ) {
160                sir1 = floor2( si, si ); sir2 = floor2( si + 2hh, si ); sir3 = floor2( -si - 2hh, si );
161                printf( "floor2(%hd, %hd) = %hd, floor2(%hd, %hd) = %hd, floor2(%hd, %hd) = %hd\n", si, si, sir1, si + 2h, si, sir2, -si - 2h, si, sir3 );
162        } // for
163        printf( "\n" );
164
165        printf( "unsigned short int\n" );
166        usi = 0;
167        usir1 = floor2( usi, usi ), usir2 = floor2( usi + 2hh, usi ), usir3 = floor2( -usi - 2hh, usi );
168        printf( "floor2(%hu, %hu) = %hu, floor2(%hu, %hu) = %hu, floor2(%hu, %hu) = %hu\n", usi, usi, usir1, usi + 2uh, usi, usir2, -usi - 2uh, usi, usir3 );
169        for ( usi = 1; usi != 0; usi <<= 1 ) {
170                usir1 = floor2( usi, usi ); usir2 = floor2( usi + 2hh, usi ); usir3 = floor2( -usi - 2hh, usi );
171                printf( "floor2(%hu, %hu) = %hu, floor2(%hu, %hu) = %hu, floor2(%hu, %hu) = %hu\n", usi, usi, usir1, usi + 2uh, usi, usir2, -usi - 2uh, usi, usir3 );
172        } // for
173        printf( "\n" );
174
175        printf( "int\n" );
176        i = 0;
177        ir1 = floor2( i, i ), ir2 = floor2( i + 2hh, i ), ir3 = floor2( -i - 2hh, i );
178        printf( "floor2(%d, %d) = %d, floor2(%d, %d) = %d, floor2(%d, %d) = %d\n", i, i, ir1, i + 2h, i, ir2, -i - 2h, i, ir3 );
179        for ( i = 1; i != 0; i <<= 1 ) {
180                ir1 = floor2( i, i ); ir2 = floor2( i + 2hh, i ); ir3 = floor2( -i - 2hh, i );
181                printf( "floor2(%d, %d) = %d, floor2(%d, %d) = %d, floor2(%d, %d) = %d\n", i, i, ir1, i + 2h, i, ir2, -i - 2h, i, ir3 );
182        } // for
183        printf( "\n" );
184
185        printf( "unsigned int\n" );
186        ui = 0;
187        uir1 = floor2( ui, ui ), uir2 = floor2( ui + 2hh, ui ), uir3 = floor2( -ui - 2hh, ui );
188        printf( "floor2(%u, %u) = %u, floor2(%u, %u) = %u, floor2(%u, %u) = %u\n", ui, ui, uir1, ui + 2h, ui, uir2, -ui - 2h, ui, uir3 );
189        for ( ui = 1; ui != 0; ui <<= 1 ) {
190                uir1 = floor2( ui, ui ); uir2 = floor2( ui + 2hh, ui ); uir3 = floor2( -ui - 2hh, ui );
191                printf( "floor2(%u, %u) = %u, floor2(%u, %u) = %u, floor2(%u, %u) = %u\n", ui, ui, uir1, ui + 2h, ui, uir2, -ui - 2h, ui, uir3 );
192        } // for
193        printf( "\n" );
194
195        printf( "long int\n" );
196        li = 0;
197        lir1 = floor2( li, li ), lir2 = floor2( li + 2hh, li ), lir3 = floor2( -li - 2hh, li );
198        printf( "floor2(%ld, %ld) = %ld, floor2(%ld, %ld) = %ld, floor2(%ld, %ld) = %ld\n", li, li, lir1, li + 2h, li, lir2, -li - 2h, li, lir3 );
199        for ( li = 1; li != 0; li <<= 1 ) {
200                lir1 = floor2( li, li ); lir2 = floor2( li + 2hh, li ); lir3 = floor2( -li - 2hh, li );
201                printf( "floor2(%ld, %ld) = %ld, floor2(%ld, %ld) = %ld, floor2(%ld, %ld) = %ld\n", li, li, lir1, li + 2h, li, lir2, -li - 2h, li, lir3 );
202        } // for
203        printf( "\n" );
204
205        printf( "unsigned long int\n" );
206        uli = 0;
207        ulir1 = floor2( uli, uli ), ulir2 = floor2( uli + 2hh, uli ), ulir3 = floor2( -uli - 2hh, uli );
208        printf( "floor2(%lu, %lu) = %lu, floor2(%lu, %lu) = %lu, floor2(%lu, %lu) = %lu\n", uli, uli, ulir1, uli + 2h, uli, ulir2, -uli - 2h, uli, ulir3 );
209        for ( uli = 1; uli != 0; uli <<= 1 ) {
210                ulir1 = floor2( uli, uli ); ulir2 = floor2( uli + 2hh, uli ); ulir3 = floor2( -uli - 2hh, uli );
211                printf( "floor2(%lu, %lu) = %lu, floor2(%lu, %lu) = %lu, floor2(%lu, %lu) = %lu\n", uli, uli, ulir1, uli + 2h, uli, ulir2, -uli - 2h, uli, ulir3 );
212        } // for
213        printf( "\n" );
214
215        printf( "long long int\n" );
216        lli = 0;
217        llir1 = floor2( lli, lli ), llir2 = floor2( lli + 2hh, lli ), llir3 = floor2( -lli - 2hh, lli );
218        printf( "floor2(%lld, %lld) = %lld, floor2(%lld, %lld) = %lld, floor2(%lld, %lld) = %lld\n", lli, lli, llir1, lli + 2h, lli, llir2, -lli - 2h, lli, llir3 );
219        for ( lli = 1; lli != 0; lli <<= 1 ) {
220                llir1 = floor2( lli, lli ); llir2 = floor2( lli + 2hh, lli ); llir3 = floor2( -lli - 2hh, lli );
221                printf( "floor2(%lld, %lld) = %lld, floor2(%lld, %lld) = %lld, floor2(%lld, %lld) = %lld\n", lli, lli, llir1, lli + 2h, lli, llir2, -lli - 2h, lli, llir3 );
222        } // for
223        printf( "\n" );
224
225        printf( "unsigned long long int\n" );
226        ulli = 0;
227        ullir1 = floor2( ulli, ulli ), ullir2 = floor2( ulli + 2hh, ulli ), ullir3 = floor2( -ulli - 2hh, ulli );
228        printf( "floor2(%llu, %llu) = %llu, floor2(%llu, %llu) = %llu, floor2(%llu, %llu) = %llu\n", ulli, ulli, ullir1, ulli + 2h, ulli, ullir2, -ulli - 2h, ulli, ullir3 );
229        for ( ulli = 1; ulli != 0; ulli <<= 1 ) {
230                ullir1 = floor2( ulli, ulli ); ullir2 = floor2( ulli + 2hh, ulli ); ullir3 = floor2( -ulli - 2hh, ulli );
231                printf( "floor2(%llu, %llu) = %llu, floor2(%llu, %llu) = %llu, floor2(%llu, %llu) = %llu\n", ulli, ulli, ullir1, ulli + 2h, ulli, ullir2, -ulli - 2h, ulli, ullir3 );
232        } // for
233        printf( "\n" );
234#endif // 0
235        //============================================================
236#if 1
237        sout | nl | "floor" | nl | nl;
238
239        printf( "signed char\n" );
240        for ( sc = 1; sc != 0; sc <<= 1 ) {
241                scr1 = floor( sc, sc ); scr2 = floor( sc + 2hh, sc ); scr3 = floor( -sc - 2hh, sc );
242                printf( "floor(%hhd, %hhd) = %hhd, floor(%hhd, %hhd) = %hhd, floor(%hhd, %hhd) = %hhd\n", sc, sc, scr1, sc + 2hh, sc, scr2, -sc - 2hh, sc, scr3 );
243        } // for
244        printf( "\n" );
245
246        printf( "unsigned char\n" );
247        for ( uc = 1; uc != 0; uc <<= 1 ) {
248                ucr1 = floor( uc, uc ); ucr2 = floor( uc + 2hh, uc ); ucr3 = floor( -uc - 2hh, uc );
249                printf( "floor(%hhu, %hhu) = %hhu, floor(%hhu, %hhu) = %hhu, floor(%hhu, %hhu) = %hhu\n", uc, uc, ucr1, uc + 2uhh, uc, ucr2, -uc - 2uhh, uc, ucr3 );
250        } // for
251        printf( "\n" );
252
253        printf( "short int\n" );
254        for ( si = 1; si != 0; si <<= 1 ) {
255                sir1 = floor( si, si ); sir2 = floor( si + 2hh, si ); sir3 = floor( -si - 2hh, si );
256                printf( "floor(%hd, %hd) = %hd, floor(%hd, %hd) = %hd, floor(%hd, %hd) = %hd\n", si, si, sir1, si + 2h, si, sir2, -si - 2h, si, sir3 );
257        } // for
258        printf( "\n" );
259
260        printf( "unsigned short int\n" );
261        for ( usi = 1; usi != 0; usi <<= 1 ) {
262                usir1 = floor( usi, usi ); usir2 = floor( usi + 2hh, usi ); usir3 = floor( -usi - 2hh, usi );
263                printf( "floor(%hu, %hu) = %hu, floor(%hu, %hu) = %hu, floor(%hu, %hu) = %hu\n", usi, usi, usir1, usi + 2uh, usi, usir2, -usi - 2uh, usi, usir3 );
264        } // for
265        printf( "\n" );
266
267        printf( "int\n" );
268        for ( i = 1; i != 0; i <<= 1 ) {
269                ir1 = floor( i, i ); ir2 = floor( i + 2hh, i ); ir3 = floor( -i - 2hh, i );
270                printf( "floor(%d, %d) = %d, floor(%d, %d) = %d, floor(%d, %d) = %d\n", i, i, ir1, i + 2h, i, ir2, -i - 2h, i, ir3 );
271        } // for
272        printf( "\n" );
273
274        printf( "unsigned int\n" );
275        for ( ui = 1; ui != 0; ui <<= 1 ) {
276                uir1 = floor( ui, ui ); uir2 = floor( ui + 2hh, ui ); uir3 = floor( -ui - 2hh, ui );
277                printf( "floor(%u, %u) = %u, floor(%u, %u) = %u, floor(%u, %u) = %u\n", ui, ui, uir1, ui + 2h, ui, uir2, -ui - 2h, ui, uir3 );
278        } // for
279        printf( "\n" );
280
281        printf( "long int\n" );
282        for ( li = 1; li != 0; li <<= 1 ) {
283                lir1 = floor( li, li ); lir2 = floor( li + 2hh, li ); lir3 = floor( -li - 2hh, li );
284                printf( "floor(%ld, %ld) = %ld, floor(%ld, %ld) = %ld, floor(%ld, %ld) = %ld\n", li, li, lir1, li + 2h, li, lir2, -li - 2h, li, lir3 );
285        } // for
286        printf( "\n" );
287
288        printf( "unsigned long int\n" );
289        for ( uli = 1; uli != 0; uli <<= 1 ) {
290                ulir1 = floor( uli, uli ); ulir2 = floor( uli + 2hh, uli ); ulir3 = floor( -uli - 2hh, uli );
291                printf( "floor(%lu, %lu) = %lu, floor(%lu, %lu) = %lu, floor(%lu, %lu) = %lu\n", uli, uli, ulir1, uli + 2h, uli, ulir2, -uli - 2h, uli, ulir3 );
292        } // for
293        printf( "\n" );
294
295        printf( "long long int\n" );
296        for ( lli = 1; lli != 0; lli <<= 1 ) {
297                llir1 = floor( lli, lli ); llir2 = floor( lli + 2hh, lli ); llir3 = floor( -lli - 2hh, lli );
298                printf( "floor(%lld, %lld) = %lld, floor(%lld, %lld) = %lld, floor(%lld, %lld) = %lld\n", lli, lli, llir1, lli + 2h, lli, llir2, -lli - 2h, lli, llir3 );
299        } // for
300        printf( "\n" );
301
302        printf( "unsigned long long int\n" );
303        for ( ulli = 1; ulli != 0; ulli <<= 1 ) {
304                ullir1 = floor( ulli, ulli ); ullir2 = floor( ulli + 2hh, ulli ); ullir3 = floor( -ulli - 2hh, ulli );
305                printf( "floor(%llu, %llu) = %llu, floor(%llu, %llu) = %llu, floor(%llu, %llu) = %llu\n", ulli, ulli, ullir1, ulli + 2h, ulli, ullir2, -ulli - 2h, ulli, ullir3 );
306        } // for
307        printf( "\n" );
308#endif // 0
309        //============================================================
310#if 1
311        sout | nl | "ceiling2" | nl | nl;
312
313        printf( "signed char\n" );
314        sc = 0;
315        scr1 = ceiling2( sc, sc ), scr2 = ceiling2( sc + 2hh, sc ), scr3 = ceiling2( -sc - 2hh, sc );
316        printf( "ceiling2(%hhd, %hhd) = %hhd, ceiling2(%hhd, %hhd) = %hhd, ceiling2(%hhd, %hhd) = %hhd\n", sc, sc, scr1, sc + 2hh, sc, scr2, -sc - 2hh, sc, scr3 );
317        for ( sc = 1; sc != 0; sc <<= 1 ) {
318                scr1 = ceiling2( sc, sc ); scr2 = ceiling2( sc + 2hh, sc ); scr3 = ceiling2( -sc - 2hh, sc );
319                printf( "ceiling2(%hhd, %hhd) = %hhd, ceiling2(%hhd, %hhd) = %hhd, ceiling2(%hhd, %hhd) = %hhd\n", sc, sc, scr1, sc + 2hh, sc, scr2, -sc - 2hh, sc, scr3 );
320        } // for
321        printf( "\n" );
322
323        printf( "unsigned char\n" );
324        uc = 0;
325        ucr1 = ceiling2( uc, uc ), ucr2 = ceiling2( uc + 2hh, uc ), ucr3 = ceiling2( -uc - 2hh, uc );
326        printf( "ceiling2(%hhu, %hhu) = %hhu, ceiling2(%hhu, %hhu) = %hhu, ceiling2(%hhu, %hhu) = %hhu\n", uc, uc, ucr1, uc + 2uhh, uc, ucr2, -uc - 2uhh, uc, ucr3 );
327        for ( uc = 1; uc != 0; uc <<= 1 ) {
328                ucr1 = ceiling2( uc, uc ); ucr2 = ceiling2( uc + 2hh, uc ); ucr3 = ceiling2( -uc - 2hh, uc );
329                printf( "ceiling2(%hhu, %hhu) = %hhu, ceiling2(%hhu, %hhu) = %hhu, ceiling2(%hhu, %hhu) = %hhu\n", uc, uc, ucr1, uc + 2uhh, uc, ucr2, -uc - 2uhh, uc, ucr3 );
330        } // for
331        printf( "\n" );
332
333        printf( "short int\n" );
334        si = 0;
335        sir1 = ceiling2( si, si ), sir2 = ceiling2( si + 2hh, si ), sir3 = ceiling2( -si - 2hh, si );
336        printf( "ceiling2(%hd, %hd) = %hd, ceiling2(%hd, %hd) = %hd, ceiling2(%hd, %hd) = %hd\n", si, si, sir1, si + 2h, si, sir2, -si - 2h, si, sir3 );
337        for ( si = 1; si != 0; si <<= 1 ) {
338                sir1 = ceiling2( si, si ); sir2 = ceiling2( si + 2hh, si ); sir3 = ceiling2( -si - 2hh, si );
339                printf( "ceiling2(%hd, %hd) = %hd, ceiling2(%hd, %hd) = %hd, ceiling2(%hd, %hd) = %hd\n", si, si, sir1, si + 2h, si, sir2, -si - 2h, si, sir3 );
340        } // for
341        printf( "\n" );
342
343        printf( "unsigned short int\n" );
344        usi = 0;
345        usir1 = ceiling2( usi, usi ), usir2 = ceiling2( usi + 2hh, usi ), usir3 = ceiling2( -usi - 2hh, usi );
346        printf( "ceiling2(%hu, %hu) = %hu, ceiling2(%hu, %hu) = %hu, ceiling2(%hu, %hu) = %hu\n", usi, usi, usir1, usi + 2uh, usi, usir2, -usi - 2uh, usi, usir3 );
347        for ( usi = 1; usi != 0; usi <<= 1 ) {
348                usir1 = ceiling2( usi, usi ); usir2 = ceiling2( usi + 2hh, usi ); usir3 = ceiling2( -usi - 2hh, usi );
349                printf( "ceiling2(%hu, %hu) = %hu, ceiling2(%hu, %hu) = %hu, ceiling2(%hu, %hu) = %hu\n", usi, usi, usir1, usi + 2uh, usi, usir2, -usi - 2uh, usi, usir3 );
350        } // for
351        printf( "\n" );
352
353        printf( "int\n" );
354        i = 0;
355        ir1 = ceiling2( i, i ), ir2 = ceiling2( i + 2hh, i ), ir3 = ceiling2( -i - 2hh, i );
356        printf( "ceiling2(%d, %d) = %d, ceiling2(%d, %d) = %d, ceiling2(%d, %d) = %d\n", i, i, ir1, i + 2h, i, ir2, -i - 2h, i, ir3 );
357        for ( i = 1; i != 0; i <<= 1 ) {
358                ir1 = ceiling2( i, i ); ir2 = ceiling2( i + 2hh, i ); ir3 = ceiling2( -i - 2hh, i );
359                printf( "ceiling2(%d, %d) = %d, ceiling2(%d, %d) = %d, ceiling2(%d, %d) = %d\n", i, i, ir1, i + 2h, i, ir2, -i - 2h, i, ir3 );
360        } // for
361        printf( "\n" );
362
363        printf( "unsigned int\n" );
364        ui = 0;
365        uir1 = ceiling2( ui, ui ), uir2 = ceiling2( ui + 2hh, ui ), uir3 = ceiling2( -ui - 2hh, ui );
366        printf( "ceiling2(%u, %u) = %u, ceiling2(%u, %u) = %u, ceiling2(%u, %u) = %u\n", ui, ui, uir1, ui + 2h, ui, uir2, -ui - 2h, ui, uir3 );
367        for ( ui = 1; ui != 0; ui <<= 1 ) {
368                uir1 = ceiling2( ui, ui ); uir2 = ceiling2( ui + 2hh, ui ); uir3 = ceiling2( -ui - 2hh, ui );
369                printf( "ceiling2(%u, %u) = %u, ceiling2(%u, %u) = %u, ceiling2(%u, %u) = %u\n", ui, ui, uir1, ui + 2h, ui, uir2, -ui - 2h, ui, uir3 );
370        } // for
371        printf( "\n" );
372
373        printf( "long int\n" );
374        li = 0;
375        lir1 = ceiling2( li, li ), lir2 = ceiling2( li + 2hh, li ), lir3 = ceiling2( -li - 2hh, li );
376        printf( "ceiling2(%ld, %ld) = %ld, ceiling2(%ld, %ld) = %ld, ceiling2(%ld, %ld) = %ld\n", li, li, lir1, li + 2h, li, lir2, -li - 2h, li, lir3 );
377        for ( li = 1; li != 0; li <<= 1 ) {
378                lir1 = ceiling2( li, li ); lir2 = ceiling2( li + 2hh, li ); lir3 = ceiling2( -li - 2hh, li );
379                printf( "ceiling2(%ld, %ld) = %ld, ceiling2(%ld, %ld) = %ld, ceiling2(%ld, %ld) = %ld\n", li, li, lir1, li + 2h, li, lir2, -li - 2h, li, lir3 );
380        } // for
381        printf( "\n" );
382
383        printf( "unsigned long int\n" );
384        uli = 0;
385        ulir1 = ceiling2( uli, uli ), ulir2 = ceiling2( uli + 2hh, uli ), ulir3 = ceiling2( -uli - 2hh, uli );
386        printf( "ceiling2(%lu, %lu) = %lu, ceiling2(%lu, %lu) = %lu, ceiling2(%lu, %lu) = %lu\n", uli, uli, ulir1, uli + 2h, uli, ulir2, -uli - 2h, uli, ulir3 );
387        for ( uli = 1; uli != 0; uli <<= 1 ) {
388                ulir1 = ceiling2( uli, uli ); ulir2 = ceiling2( uli + 2hh, uli ); ulir3 = ceiling2( -uli - 2hh, uli );
389                printf( "ceiling2(%lu, %lu) = %lu, ceiling2(%lu, %lu) = %lu, ceiling2(%lu, %lu) = %lu\n", uli, uli, ulir1, uli + 2h, uli, ulir2, -uli - 2h, uli, ulir3 );
390        } // for
391        printf( "\n" );
392
393        printf( "long long int\n" );
394        lli = 0;
395        llir1 = ceiling2( lli, lli ), llir2 = ceiling2( lli + 2hh, lli ), llir3 = ceiling2( -lli - 2hh, lli );
396        printf( "ceiling2(%lld, %lld) = %lld, ceiling2(%lld, %lld) = %lld, ceiling2(%lld, %lld) = %lld\n", lli, lli, llir1, lli + 2h, lli, llir2, -lli - 2h, lli, llir3 );
397        for ( lli = 1; lli != 0; lli <<= 1 ) {
398                llir1 = ceiling2( lli, lli ); llir2 = ceiling2( lli + 2hh, lli ); llir3 = ceiling2( -lli - 2hh, lli );
399                printf( "ceiling2(%lld, %lld) = %lld, ceiling2(%lld, %lld) = %lld, ceiling2(%lld, %lld) = %lld\n", lli, lli, llir1, lli + 2h, lli, llir2, -lli - 2h, lli, llir3 );
400        } // for
401        printf( "\n" );
402
403        printf( "unsigned long long int\n" );
404        ulli = 0;
405        ullir1 = ceiling2( ulli, ulli ), ullir2 = ceiling2( ulli + 2hh, ulli ), ullir3 = ceiling2( -ulli - 2hh, ulli );
406        printf( "ceiling2(%llu, %llu) = %llu, ceiling2(%llu, %llu) = %llu, ceiling2(%llu, %llu) = %llu\n", ulli, ulli, ullir1, ulli + 2h, ulli, ullir2, -ulli - 2h, ulli, ullir3 );
407        for ( ulli = 1; ulli != 0; ulli <<= 1 ) {
408                ullir1 = ceiling2( ulli, ulli ); ullir2 = ceiling2( ulli + 2hh, ulli ); ullir3 = ceiling2( -ulli - 2hh, ulli );
409                printf( "ceiling2(%llu, %llu) = %llu, ceiling2(%llu, %llu) = %llu, ceiling2(%llu, %llu) = %llu\n", ulli, ulli, ullir1, ulli + 2h, ulli, ullir2, -ulli - 2h, ulli, ullir3 );
410        } // for
411        printf( "\n" );
412#endif // 0
413        //============================================================
414#if 1
415        sout | nl | "ceiling" | nl | nl;
416
417        printf( "signed char\n" );
418        for ( sc = 1; sc != 0; sc <<= 1 ) {
419                scr1 = ceiling( sc, sc ); scr2 = ceiling( sc + 2hh, sc ); scr3 = ceiling( -sc - 2hh, sc );
420                printf( "ceiling(%hhd, %hhd) = %hhd, ceiling(%hhd, %hhd) = %hhd, ceiling(%hhd, %hhd) = %hhd\n", sc, sc, scr1, sc + 2hh, sc, scr2, -sc - 2hh, sc, scr3 );
421        } // for
422        printf( "\n" );
423
424        printf( "unsigned char\n" );
425        for ( uc = 1; uc != 0; uc <<= 1 ) {
426                ucr1 = ceiling( uc, uc ); ucr2 = ceiling( uc + 2hh, uc ); ucr3 = ceiling( -uc - 2hh, uc );
427                printf( "ceiling(%hhu, %hhu) = %hhu, ceiling(%hhu, %hhu) = %hhu, ceiling(%hhu, %hhu) = %hhu\n", uc, uc, ucr1, uc + 2uhh, uc, ucr2, -uc - 2uhh, uc, ucr3 );
428        } // for
429        printf( "\n" );
430
431        printf( "short int\n" );
432        for ( si = 1; si != 0; si <<= 1 ) {
433                sir1 = ceiling( si, si ); sir2 = ceiling( si + 2hh, si ); sir3 = ceiling( -si - 2hh, si );
434                printf( "ceiling(%hd, %hd) = %hd, ceiling(%hd, %hd) = %hd, ceiling(%hd, %hd) = %hd\n", si, si, sir1, si + 2h, si, sir2, -si - 2h, si, sir3 );
435        } // for
436        printf( "\n" );
437
438        printf( "unsigned short int\n" );
439        for ( usi = 1; usi != 0; usi <<= 1 ) {
440                usir1 = ceiling( usi, usi ); usir2 = ceiling( usi + 2hh, usi ); usir3 = ceiling( -usi - 2hh, usi );
441                printf( "ceiling(%hu, %hu) = %hu, ceiling(%hu, %hu) = %hu, ceiling(%hu, %hu) = %hu\n", usi, usi, usir1, usi + 2uh, usi, usir2, -usi - 2uh, usi, usir3 );
442        } // for
443        printf( "\n" );
444
445        printf( "int\n" );
446        for ( i = 1; i != 0; i <<= 1 ) {
447                ir1 = ceiling( i, i ); ir2 = ceiling( i + 2hh, i ); ir3 = ceiling( -i - 2hh, i );
448                printf( "ceiling(%d, %d) = %d, ceiling(%d, %d) = %d, ceiling(%d, %d) = %d\n", i, i, ir1, i + 2h, i, ir2, -i - 2h, i, ir3 );
449        } // for
450        printf( "\n" );
451
452        printf( "unsigned int\n" );
453        for ( ui = 1; ui != 0; ui <<= 1 ) {
454                uir1 = ceiling( ui, ui ); uir2 = ceiling( ui + 2hh, ui ); uir3 = ceiling( -ui - 2hh, ui );
455                printf( "ceiling(%u, %u) = %u, ceiling(%u, %u) = %u, ceiling(%u, %u) = %u\n", ui, ui, uir1, ui + 2h, ui, uir2, -ui - 2h, ui, uir3 );
456        } // for
457        printf( "\n" );
458
459        printf( "long int\n" );
460        for ( li = 1; li != 0; li <<= 1 ) {
461                lir1 = ceiling( li, li ); lir2 = ceiling( li + 2hh, li ); lir3 = ceiling( -li - 2hh, li );
462                printf( "ceiling(%ld, %ld) = %ld, ceiling(%ld, %ld) = %ld, ceiling(%ld, %ld) = %ld\n", li, li, lir1, li + 2h, li, lir2, -li - 2h, li, lir3 );
463        } // for
464        printf( "\n" );
465
466        printf( "unsigned long int\n" );
467        for ( uli = 1; uli != 0; uli <<= 1 ) {
468                ulir1 = ceiling( uli, uli ); ulir2 = ceiling( uli + 2hh, uli ); ulir3 = ceiling( -uli - 2hh, uli );
469                printf( "ceiling(%lu, %lu) = %lu, ceiling(%lu, %lu) = %lu, ceiling(%lu, %lu) = %lu\n", uli, uli, ulir1, uli + 2h, uli, ulir2, -uli - 2h, uli, ulir3 );
470        } // for
471        printf( "\n" );
472
473        printf( "long long int\n" );
474        for ( lli = 1; lli != 0; lli <<= 1 ) {
475                llir1 = ceiling( lli, lli ); llir2 = ceiling( lli + 2hh, lli ); llir3 = ceiling( -lli - 2hh, lli );
476                printf( "ceiling(%lld, %lld) = %lld, ceiling(%lld, %lld) = %lld, ceiling(%lld, %lld) = %lld\n", lli, lli, llir1, lli + 2h, lli, llir2, -lli - 2h, lli, llir3 );
477        } // for
478        printf( "\n" );
479
480        printf( "unsigned long long int\n" );
481        for ( ulli = 1; ulli != 0; ulli <<= 1 ) {
482                ullir1 = ceiling( ulli, ulli ); ullir2 = ceiling( ulli + 2hh, ulli ); ullir3 = ceiling( -ulli - 2hh, ulli );
483                printf( "ceiling(%llu, %llu) = %llu, ceiling(%llu, %llu) = %llu, ceiling(%llu, %llu) = %llu\n", ulli, ulli, ullir1, ulli + 2h, ulli, ullir2, -ulli - 2h, ulli, ullir3 );
484        } // for
485        printf( "\n" );
486#endif // 0
487} // main
488
489// Local Variables: //
490// tab-width: 4 //
491// compile-command: "cfa bitmanip3.cfa" //
492// End: //
Note: See TracBrowser for help on using the repository browser.