1 | #include <fstream.hfa> |
---|
2 | int main() { |
---|
3 | int128 x = 0xffff; |
---|
4 | x <<= 64;; |
---|
5 | x += 0xffff; |
---|
6 | x = -x; |
---|
7 | sout | x; |
---|
8 | sout | sign(x); |
---|
9 | x = -x; |
---|
10 | sout | sign(x); |
---|
11 | sout | nl; |
---|
12 | #if 1 |
---|
13 | sout | bin(x); |
---|
14 | sout | upcase(bin(x)); |
---|
15 | sout | nobase(bin(x)); |
---|
16 | sout | wd( 95, upcase(bin(x)) ); |
---|
17 | sout | wd( 95,90, upcase(bin(x)) ); |
---|
18 | sout | wd( 25,30, upcase(hex(x)) ); |
---|
19 | sout | nl; |
---|
20 | |
---|
21 | printf( "%#.10o\n", 0123 ); |
---|
22 | sout | wd( 1,10, oct(0123) ); |
---|
23 | sout | oct(x); |
---|
24 | sout | nobase(oct(x)); |
---|
25 | sout | wd( 45, oct(0123) ); |
---|
26 | sout | wd( 45,40, oct(0123) ); |
---|
27 | sout | wd( 40,45, oct(0123) ); |
---|
28 | sout | wd( 45, oct(x) ); |
---|
29 | sout | wd( 45,40, oct(x) ); |
---|
30 | sout | wd( 40,45, oct(x) ); |
---|
31 | |
---|
32 | sout | left(wd( 45, oct(0123) )) | 'X'; |
---|
33 | sout | left(wd( 45, oct(x) )) | 'X'; |
---|
34 | sout | left(wd( 45,40, oct(0123) )) | 'X'; |
---|
35 | sout | left(wd( 45,40, oct(x) )) | 'X'; |
---|
36 | sout | left(wd( 40,45, oct(0123) )) | 'X'; |
---|
37 | sout | left(wd( 40,45, oct(x) )) | 'X'; |
---|
38 | printf( "%#-1.10oX\n", 0123 ); |
---|
39 | sout | left(wd( 1,10, oct(0123) )) | 'X'; |
---|
40 | printf( "%#-40.10oX\n", 0123 ); |
---|
41 | sout | left(wd( 40,10, oct(0123) )) | 'X'; |
---|
42 | sout | left(wd( 40,10, oct(x) )) | 'X'; |
---|
43 | sout | left(wd( 10,40, oct(0123) )) | 'X'; |
---|
44 | sout | left(wd( 10,40, oct(x) )) | 'X'; |
---|
45 | |
---|
46 | int128 y = 123456789; |
---|
47 | sout | left(wd( 45, 49, oct(y) )) | 'X'; |
---|
48 | sout | nl; |
---|
49 | |
---|
50 | sout | hex(x); |
---|
51 | sout | upcase(hex(x)); |
---|
52 | sout | nobase(hex(x)); |
---|
53 | sout | wd( 45, upcase(hex(x)) ); |
---|
54 | sout | wd( 45,40, upcase(hex(x)) ); |
---|
55 | sout | wd( 45,49, upcase(hex(x)) ); |
---|
56 | sout | left(wd( 45, upcase(hex(x)) )) | 'X'; |
---|
57 | sout | left(wd( 45,40, upcase(hex(x)) )) | 'X'; |
---|
58 | sout | left(wd( 45,49, upcase(hex(x)) )) | 'X'; |
---|
59 | |
---|
60 | sout | nl | nl; |
---|
61 | |
---|
62 | int128 divisor = 0x4b3b4ca85a86c47a; |
---|
63 | divisor <<= 16; |
---|
64 | divisor += 0x98a224000000000; |
---|
65 | |
---|
66 | // base 10 |
---|
67 | sout | divisor; |
---|
68 | sout | wd(2, divisor); |
---|
69 | sout | wd(3, divisor); |
---|
70 | sout | wd(10, divisor); |
---|
71 | sout | wd(24, divisor); |
---|
72 | sout | wd(38, divisor); |
---|
73 | sout | wd(39, divisor); |
---|
74 | sout | wd(40, divisor); |
---|
75 | |
---|
76 | sout | wd(40, 30, divisor); |
---|
77 | sout | wd(40, 38, divisor); |
---|
78 | sout | wd(40, 40, divisor); |
---|
79 | sout | pad0(wd(40, divisor)); |
---|
80 | sout | pad0(sign(wd(40,divisor))); |
---|
81 | |
---|
82 | // base 2 |
---|
83 | sout | upcase(bin(divisor)); |
---|
84 | sout | wd(38, upcase(bin(divisor))); |
---|
85 | sout | wd(40, upcase(bin(divisor))); |
---|
86 | sout | wd(40, 38, upcase(bin(divisor))); |
---|
87 | sout | wd(40, 30, upcase(bin(divisor))); |
---|
88 | sout | pad0(sign(wd(40, 38, upcase(bin(divisor))))); |
---|
89 | |
---|
90 | // oct |
---|
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 | |
---|
98 | // hex |
---|
99 | sout | upcase(hex(divisor)); |
---|
100 | sout | wd(38, upcase(hex(divisor))); |
---|
101 | sout | wd(40, upcase(hex(divisor))); |
---|
102 | sout | wd(40, 38, upcase(hex(divisor))); |
---|
103 | sout | wd(40, 30, upcase(hex(divisor))); |
---|
104 | sout | pad0(sign(wd(40, 38, upcase(hex(divisor))))); |
---|
105 | |
---|
106 | |
---|
107 | sout | bin(divisor); |
---|
108 | sout | upcase(bin(divisor)); |
---|
109 | sout | oct(divisor); |
---|
110 | sout | hex(divisor); |
---|
111 | sout | upcase(hex(divisor)); |
---|
112 | sout | nobase(bin(divisor)) | nobase(oct(divisor)) | nobase(hex(divisor)); |
---|
113 | sout | sign(divisor); |
---|
114 | sout | -divisor; |
---|
115 | sout | sign(-divisor); |
---|
116 | sout | wd(2, divisor); |
---|
117 | sout | wd(3,10,divisor); |
---|
118 | sout | left(wd(40,divisor)) | 'X'; |
---|
119 | sout | left(sign(wd(40, divisor))) | 'X'; |
---|
120 | sout | left(sign(wd(0,40, divisor))) | 'X'; |
---|
121 | printf( "%-+1.40dX\n", 123456789 ); |
---|
122 | #endif // 0 |
---|
123 | } |
---|