source: tests/manipulatorsOutput3.cfa @ 9ec8c5f

arm-ehjacob/cs343-translationnew-astnew-ast-unique-expr
Last change on this file since 9ec8c5f was 9ec8c5f, checked in by Peter A. Buhr <pabuhr@…>, 16 months ago

add additional int128 tests

  • Property mode set to 100644
File size: 4.9 KB
Line 
1#include <fstream.hfa>
2int main() {
3    int128 x = 0xffff, y = 0x2;
4    x <<= 64;
5    x += 0xffff;
6    y <<= 64;
7    y += 0123;
8    y |= 0x8000000000000000;
9    x = -x;
10    sout | x;
11    sout | sign(x);
12    x = -x;
13    sout | sign(x);
14    sout | nl;
15
16    sout | bin(x);
17    sout | upcase(bin(x));
18    sout | nobase(bin(x));
19    sout | wd( 95, upcase(bin(x)) );
20    sout | wd( 95,90, upcase(bin(x)) );
21    sout | wd( 25,30, upcase(hex(x)) );
22    sout | nl;
23
24    printf( "%#.10o\n", 0123 );
25    sout | wd( 1,10, oct(0123) );
26    sout | oct(x);
27    sout | nobase(oct(x));
28    sout | wd( 45, oct(0123) );
29    sout | wd( 45,40, oct(0123) );
30    sout | wd( 40,45, oct(0123) );
31    sout | wd( 45, oct(x) );
32    sout | wd( 45,40, oct(x) );
33    sout | wd( 40,45, oct(x) );
34
35    sout | left(wd( 45, oct(0123) )) | 'X';
36    sout | left(wd( 45, oct(x) )) | 'X';
37    sout | left(wd( 45, oct(y) )) | 'X';
38    sout | left(wd( 45,40, oct(0123) )) | 'X';
39    sout | left(wd( 45,40, oct(x) )) | 'X';
40    sout | left(wd( 45,40, oct(y) )) | 'X';
41    sout | left(wd( 40,45, oct(0123) )) | 'X';
42    sout | left(wd( 40,45, oct(x) )) | 'X';
43    sout | left(wd( 40,45, oct(y) )) | 'X';
44    printf( "%#-1.10oX\n", 0123 );
45    sout | left(wd( 1,10, oct(0123) )) | 'X';
46    printf( "%#-40.10oX\n", 0123 );
47    sout | left(wd( 40,10, oct(0123) )) | 'X';
48    sout | left(wd( 40,10, oct(x) )) | 'X';
49    sout | left(wd( 40,10, oct(y) )) | 'X';
50    sout | left(wd( 10,40, oct(0123) )) | 'X';
51    sout | left(wd( 10,40, oct(x) )) | 'X';
52    sout | left(wd( 10,40, oct(y) )) | 'X';
53
54    y = 01234567;
55    sout | left(wd( 45, 49, oct(y) )) | 'X';
56    y = -y;
57    sout | wd(0, oct(y)) | 'Y';
58    sout | left(wd(0, oct(y))) | 'Y';
59    sout | nl;
60
61    sout | hex(x);
62    sout | upcase(hex(x));
63    sout | nobase(hex(x));
64    sout | wd( 45, upcase(hex(x)) );
65    sout | wd( 45,40, upcase(hex(x)) );
66    sout | wd( 45,49, upcase(hex(x)) );
67    sout | left(wd( 45, upcase(hex(x)) )) | 'X';
68    sout | left(wd( 45,40, upcase(hex(x)) )) | 'X';
69    sout | left(wd( 45,49, upcase(hex(x)) )) | 'X';
70
71    sout | nl;
72
73    int128 divisor = 0x4b3b4ca85a86c47a;
74    divisor <<= 16;
75    divisor += 0x98a224000000000;
76   
77    // base 2
78    sout | "base 2";
79    sout | bin(divisor);
80    sout | upcase(bin(divisor));
81    sout | wd(38, upcase(bin(divisor)));
82    sout | wd(40, upcase(bin(divisor)));
83    sout | wd(40, 38, upcase(bin(divisor)));
84    sout | wd(40, 30, upcase(bin(divisor)));
85    sout | pad0(sign(wd(40, 38, upcase(bin(divisor)))));
86    sout | nl;
87   
88    // oct
89    sout | "base 8";
90    sout | upcase(oct(divisor));
91    sout | wd(38, upcase(oct(divisor)));
92    sout | wd(40, upcase(oct(divisor)));
93    sout | wd(40, 38, upcase(oct(divisor)));
94    sout | wd(40, 30, upcase(oct(divisor)));
95    sout | pad0(sign(wd(40, 38, upcase(oct(divisor)))));
96    sout | nl;
97
98    // decimal
99    sout | "base 10";
100    sout | divisor;
101    sout | wd(2, divisor);
102    sout | wd(3, divisor);
103    sout | wd(10, divisor);
104    sout | wd(24, divisor);
105    sout | wd(38, divisor);
106    sout | wd(39, divisor);
107    sout | wd(40, divisor);
108   
109    sout | wd(40, 30, divisor);
110    sout | wd(40, 38, divisor);
111    sout | wd(40, 40, divisor);
112    sout | pad0(wd(40, divisor));
113    sout | pad0(sign(wd(40,divisor)));
114    sout | nl;
115   
116    // hex
117    sout | "base 16";
118    sout | upcase(hex(divisor));
119    sout | wd(38, upcase(hex(divisor)));
120    sout | wd(40, upcase(hex(divisor)));
121    sout | wd(40, 38, upcase(hex(divisor)));
122    sout | wd(40, 30, upcase(hex(divisor)));
123    sout | pad0(sign(wd(40, 38, upcase(hex(divisor)))));
124    sout | nl;
125
126
127    // extras
128    sout | "extras";
129    sout | bin(divisor);
130    sout | upcase(bin(divisor));
131    sout | oct(divisor);
132    sout | hex(divisor);
133    sout | upcase(hex(divisor));
134    sout | nobase(bin(divisor)) | nobase(oct(divisor)) | nobase(hex(divisor));
135    sout | sign(divisor);
136    sout | -divisor;
137    sout | sign(-divisor);
138    sout | wd(2, divisor);
139    sout | wd(3,10,divisor);
140    sout | left(wd(40,divisor)) | 'X';
141    sout | left(sign(wd(40, divisor))) | 'X';
142    sout | left(sign(wd(0,40, divisor))) | 'X';
143    printf( "%-+1.40dX\n", 123456789 );
144
145    int128 i128;
146    unsigned int128 ui128;
147
148    i128 = -10;
149    for ( 25 ) {
150        sout | left( sign( wd( 20, i128 ) ) ) | left( wd( 20, hex( i128 ) ) ) | left( wd( 20, oct( i128 ) ) );
151        sout | left( wd( 20, bin( i128 ) ) );
152        i128 += 1;
153    }
154    sout | nl;
155
156    i128 = 0x7fffffffffffffff;
157    i128 <<= 64;
158    i128 += 0xfffffffffffffffa;
159
160    for ( 20 ) {
161        sout | i128;
162        sout | left( sign( wd( 45, i128 ) ) ) | left( wd( 45, hex( i128 ) ) ) | left( wd( 45, oct( i128 ) ) );
163        sout | left( wd( 45, bin( i128 ) ) );
164        i128 += 1;
165    }
166    sout | nl;
167
168    ui128 = 0x7fffffffffffffff;
169    ui128 <<= 64;
170    ui128 += 0xfffffffffffffffa;
171   
172    for ( 20 ) {
173        sout | ui128;
174        ui128 += 1;
175    }
176    sout | nl;
177
178    ui128 = 0xffffffffffffffff;
179    ui128 <<= 64;
180    ui128 += 0xfffffffffffffffa;
181   
182    for ( 20 ) {
183        sout | ui128;
184        ui128 += 1;
185    }
186}
Note: See TracBrowser for help on using the repository browser.