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 | sout | oct(x); |
---|
22 | sout | nobase(oct(x)); |
---|
23 | sout | wd( 45, upcase(oct(123)) ); |
---|
24 | sout | wd( 45,40, upcase(oct(123)) ); |
---|
25 | sout | wd( 40,45, upcase(oct(123)) ); |
---|
26 | sout | wd( 45, upcase(oct(x)) ); |
---|
27 | sout | wd( 45,40, upcase(oct(x)) ); |
---|
28 | sout | wd( 40,45, upcase(oct(x)) ); |
---|
29 | sout | left(wd( 45, upcase(oct(x)) )) | 'X'; |
---|
30 | int128 y = 123456789; |
---|
31 | sout | left(wd( 45, 49, upcase(oct(y)) )) | 'X'; |
---|
32 | sout | nl; |
---|
33 | |
---|
34 | sout | hex(x); |
---|
35 | sout | upcase(hex(x)); |
---|
36 | sout | nobase(hex(x)); |
---|
37 | sout | wd( 45, upcase(hex(x)) ); |
---|
38 | sout | wd( 45,40, upcase(hex(x)) ); |
---|
39 | sout | wd( 45,49, upcase(hex(x)) ); |
---|
40 | sout | left(wd( 45, upcase(hex(x)) )) | 'X'; |
---|
41 | sout | left(wd( 45,40, upcase(hex(x)) )) | 'X'; |
---|
42 | sout | left(wd( 45,49, upcase(hex(x)) )) | 'X'; |
---|
43 | |
---|
44 | sout | nl | nl; |
---|
45 | |
---|
46 | int128 divisor = 0x4b3b4ca85a86c47a; |
---|
47 | divisor <<= 16; |
---|
48 | divisor += 0x98a224000000000; |
---|
49 | |
---|
50 | // base 10 |
---|
51 | sout | divisor; |
---|
52 | sout | wd(2, divisor); |
---|
53 | sout | wd(3, divisor); |
---|
54 | sout | wd(10, divisor); |
---|
55 | sout | wd(24, divisor); |
---|
56 | sout | wd(38, divisor); |
---|
57 | sout | wd(39, divisor); |
---|
58 | sout | wd(40, divisor); |
---|
59 | |
---|
60 | sout | wd(40, 30, divisor); |
---|
61 | sout | wd(40, 38, divisor); |
---|
62 | sout | wd(40, 40, divisor); |
---|
63 | sout | pad0(wd(40, divisor)); |
---|
64 | sout | pad0(sign(wd(40,divisor))); |
---|
65 | |
---|
66 | // base 2 |
---|
67 | sout | upcase(bin(divisor)); |
---|
68 | sout | wd(38, upcase(bin(divisor))); |
---|
69 | sout | wd(40, upcase(bin(divisor))); |
---|
70 | sout | wd(40, 38, upcase(bin(divisor))); |
---|
71 | sout | wd(40, 30, upcase(bin(divisor))); |
---|
72 | sout | pad0(sign(wd(40, 38, upcase(bin(divisor))))); |
---|
73 | |
---|
74 | // oct |
---|
75 | sout | upcase(oct(divisor)); |
---|
76 | sout | wd(38, upcase(oct(divisor))); |
---|
77 | sout | wd(40, upcase(oct(divisor))); |
---|
78 | sout | wd(40, 38, upcase(oct(divisor))); |
---|
79 | sout | wd(40, 30, upcase(oct(divisor))); |
---|
80 | sout | pad0(sign(wd(40, 38, upcase(oct(divisor))))); |
---|
81 | |
---|
82 | // hex |
---|
83 | sout | upcase(hex(divisor)); |
---|
84 | sout | wd(38, upcase(hex(divisor))); |
---|
85 | sout | wd(40, upcase(hex(divisor))); |
---|
86 | sout | wd(40, 38, upcase(hex(divisor))); |
---|
87 | sout | wd(40, 30, upcase(hex(divisor))); |
---|
88 | sout | pad0(sign(wd(40, 38, upcase(hex(divisor))))); |
---|
89 | |
---|
90 | |
---|
91 | sout | bin(divisor); |
---|
92 | sout | upcase(bin(divisor)); |
---|
93 | sout | oct(divisor); |
---|
94 | sout | hex(divisor); |
---|
95 | sout | upcase(hex(divisor)); |
---|
96 | sout | nobase(bin(divisor)) | nobase(oct(divisor)) | nobase(hex(divisor)); |
---|
97 | sout | sign(divisor); |
---|
98 | sout | -divisor; |
---|
99 | sout | sign(-divisor); |
---|
100 | sout | wd(2, divisor); |
---|
101 | sout | wd(3,10,divisor); |
---|
102 | sout | left(wd(40,divisor)) | 'X'; |
---|
103 | sout | left(sign(wd(40, divisor))) | 'X'; |
---|
104 | sout | left(sign(wd(0,40, divisor))) | 'X'; |
---|
105 | printf( "%-+1.40dX\n", 123456789 ); |
---|
106 | #endif // 0 |
---|
107 | } |
---|