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