 Timestamp:
 Jul 11, 2020, 6:40:27 PM (4 years ago)
 Branches:
 ADT, armeh, astexperimental, enum, forallpointerdecay, jacob/cs343translation, master, newast, newastuniqueexpr, pthreademulation, qualifiedEnum
 Children:
 d34575b
 Parents:
 9f350c4
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

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