Changeset f5d4f62


Ignore:
Timestamp:
Jul 14, 2020, 1:39:15 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
0aec496
Parents:
e1801fc (diff), b4cd58ed (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Files:
1 added
10 deleted
9 edited
1 moved

Legend:

Unmodified
Added
Removed
  • libcfa/prelude/builtins.c

    re1801fc rf5d4f62  
    1010// Created On       : Fri Jul 21 16:21:03 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov 21 16:31:39 2019
    13 // Update Count     : 101
     12// Last Modified On : Mon Jul 13 21:10:02 2020
     13// Update Count     : 109
    1414//
    1515
     
    9595static inline forall( dtype DT ) DT * intptr( uintptr_t addr ) { return (DT *)addr; }
    9696
     97#if defined(__SIZEOF_INT128__)
     98// constructor for 128-bit numbers (all constants are unsigned as +/- are operators)
     99static inline void ?{}( unsigned int128 & this, unsigned long int h, unsigned long int l ) {
     100        this = (unsigned int128)h << 64 | (unsigned int128)l;
     101} // ?{}
     102#endif // __SIZEOF_INT128__
     103
    97104// exponentiation operator implementation
    98105
  • libcfa/src/Makefile.am

    re1801fc rf5d4f62  
    4040if BUILDLIB
    4141headers_nosrc = bitmanip.hfa exception.hfa math.hfa gmp.hfa time_t.hfa clock.hfa \
    42                 bits/align.hfa bits/containers.hfa bits/defs.hfa bits/debug.hfa bits/locks.hfa containers/list.hfa containers/stackLockFree.hfa
     42                bits/align.hfa bits/containers.hfa bits/defs.hfa bits/debug.hfa bits/locks.hfa \
     43                containers/list.hfa containers/stackLockFree.hfa concurrency/iofwd.hfa
     44
    4345headers = common.hfa fstream.hfa heap.hfa iostream.hfa iterator.hfa limits.hfa rational.hfa \
    4446                time.hfa stdlib.hfa memory.hfa \
  • libcfa/src/Makefile.in

    re1801fc rf5d4f62  
    246246        bits/align.hfa bits/containers.hfa bits/defs.hfa \
    247247        bits/debug.hfa bits/locks.hfa containers/list.hfa \
    248         containers/stackLockFree.hfa concurrency/coroutine.hfa \
    249         concurrency/thread.hfa concurrency/kernel.hfa \
    250         concurrency/monitor.hfa concurrency/mutex.hfa \
    251         concurrency/invoke.h
     248        containers/stackLockFree.hfa concurrency/iofwd.hfa \
     249        concurrency/coroutine.hfa concurrency/thread.hfa \
     250        concurrency/kernel.hfa concurrency/monitor.hfa \
     251        concurrency/mutex.hfa concurrency/invoke.h
    252252HEADERS = $(nobase_cfa_include_HEADERS)
    253253am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
     
    470470#----------------------------------------------------------------------------------------------------------------
    471471@BUILDLIB_TRUE@headers_nosrc = bitmanip.hfa exception.hfa math.hfa gmp.hfa time_t.hfa clock.hfa \
    472 @BUILDLIB_TRUE@         bits/align.hfa bits/containers.hfa bits/defs.hfa bits/debug.hfa bits/locks.hfa containers/list.hfa containers/stackLockFree.hfa
     472@BUILDLIB_TRUE@         bits/align.hfa bits/containers.hfa bits/defs.hfa bits/debug.hfa bits/locks.hfa \
     473@BUILDLIB_TRUE@         containers/list.hfa containers/stackLockFree.hfa concurrency/iofwd.hfa
    473474
    474475@BUILDLIB_FALSE@headers =
  • libcfa/src/concurrency/kernel.cfa

    re1801fc rf5d4f62  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 26 22:05:19 2020
    13 // Update Count     : 59
     12// Last Modified On : Thu Jul  9 06:22:54 2020
     13// Update Count     : 66
    1414//
    1515
     
    148148//-----------------------------------------------------------------------------
    149149// Global state
    150 thread_local struct KernelThreadData kernelTLS __attribute__ ((tls_model ( "initial-exec" ))) = {
     150thread_local struct KernelThreadData kernelTLS __attribute__ ((tls_model ( "initial-exec" ))) @= {
    151151        NULL,                                                                                           // cannot use 0p
    152152        NULL,
    153153        NULL,
    154154        { 1, false, false },
    155         6u //this should be seeded better but due to a bug calling rdtsc doesn't work
    156155};
    157156
  • libcfa/src/iostream.cfa

    re1801fc rf5d4f62  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jul  6 08:49:48 2020
    13 // Update Count     : 1064
     12// Last Modified On : Wed Jul  8 22:14:20 2020
     13// Update Count     : 1069
    1414//
    1515
     
    675675                f.val = val % power;
    676676                if ( cnt == 1 && f.flags.left ) { wd = f.wd; f.wd = maxdig; } // copy f.wd and reset for printing middle chunk
     677                // printf( "R val:%#lx(%lu) wd:%u pc:%u base:%c neg:%d pc:%d left:%d nobsdp:%d sign:%d pad0:%d\n",
     678                //              f.val, f.val, f.wd, f.pc, f.base, f.flags.neg, f.flags.pc, f.flags.left, f.flags.nobsdp, f.flags.sign, f.flags.pad0 );
    677679                (ostype &)(os | f);
    678680                if ( cnt == 1 ) {
     
    715717
    716718                if ( f.flags.neg ) f.val = -f.val;
     719                // printf( "L val:%#lx(%lu) wd:%u pc:%u base:%c neg:%d pc:%d left:%d nobsdp:%d sign:%d pad0:%d\n",
     720                //              f.val, f.val, f.wd, f.pc, f.base, f.flags.neg, f.flags.pc, f.flags.left, f.flags.nobsdp, f.flags.sign, f.flags.pad0 );
    717721                (ostype &)(os | f);
    718722
  • libcfa/src/iostream.hfa

    re1801fc rf5d4f62  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul  4 18:31:48 2020
    13 // Update Count     : 343
     12// Last Modified On : Mon Jul 13 22:11:41 2020
     13// Update Count     : 344
    1414//
    1515
     
    216216IntegralFMTDecl( int128, 'd' )
    217217IntegralFMTDecl( unsigned int128, 'u' )
    218 #endif
     218#endif // __SIZEOF_INT128__
    219219
    220220// *********************************** floating point ***********************************
  • src/Parser/ExpressionNode.cc

    re1801fc rf5d4f62  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 18 21:14:58 2019
    13 // Update Count     : 981
     12// Last Modified On : Mon Jul 13 21:12:02 2020
     13// Update Count     : 1043
    1414//
    1515
     
    8585        } // if
    8686        // remove "lL" for these cases because it may not imply long
    87         str.erase( posn );                                                                      // remove length
     87        str.erase( posn );                                                                      // remove length suffix and "uU"
    8888} // lnthSuffix
    8989
     
    108108} // valueToType
    109109
     110static void scanbin( string & str, unsigned long long int & v ) {
     111        v = 0;
     112        size_t last = str.length() - 1;                                         // last subscript of constant
     113        for ( unsigned int i = 2;; ) {                                          // ignore prefix
     114                if ( str[i] == '1' ) v |= 1;
     115                i += 1;
     116          if ( i == last - 1 || (str[i] != '0' && str[i] != '1') ) break;
     117                v <<= 1;
     118        } // for
     119} // scanbin
     120
    110121Expression * build_constantInteger( string & str ) {
    111122        static const BasicType::Kind kind[2][6] = {
    112123                // short (h) must be before char (hh) because shorter type has the longer suffix
    113                 { BasicType::ShortSignedInt, BasicType::SignedChar, BasicType::SignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt, BasicType::SignedInt128, },
    114                 { BasicType::ShortUnsignedInt, BasicType::UnsignedChar, BasicType::UnsignedInt, BasicType::LongUnsignedInt, BasicType::LongLongUnsignedInt, BasicType::UnsignedInt128, },
     124                { BasicType::ShortSignedInt, BasicType::SignedChar, BasicType::SignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt, /* BasicType::SignedInt128 */ BasicType::LongLongSignedInt, },
     125                { BasicType::ShortUnsignedInt, BasicType::UnsignedChar, BasicType::UnsignedInt, BasicType::LongUnsignedInt, BasicType::LongLongUnsignedInt, /* BasicType::UnsignedInt128 */ BasicType::LongLongUnsignedInt, },
    115126        };
    116127
     
    120131        }; // lnthsInt
    121132
    122         unsigned long long int v;                                                       // converted integral value
    123         size_t last = str.length() - 1;                                         // last subscript of constant
    124         Expression * ret;
    125         //string fred( str );
     133        string str2( "0x0" );
     134        unsigned long long int v, v2 = 0;                                       // converted integral value
     135        Expression * ret, * ret2;
    126136
    127137        int type = -1;                                                                          // 0 => short, 1 => char, 2 => int, 3 => long int, 4 => long long int, 5 => int128
     
    139149        } // if
    140150
     151        string::size_type posn;
     152
     153        // 'u' can appear before or after length suffix
     154        if ( str.find_last_of( "uU" ) != string::npos ) Unsigned = true;
     155
     156        if ( isdigit( str[str.length() - 1] ) ) {                       // no suffix ?
     157                lnthSuffix( str, type, ltype );                                 // could have length suffix
     158                if ( type == 5 && Unsigned ) str.erase( str.length() - 1 ); // L128 and terminating "uU" ?
     159        } else {
     160                // At least one digit in integer constant, so safe to backup while looking for suffix.
     161
     162                posn = str.find_last_of( "pP" );                                // pointer value
     163                if ( posn != string::npos ) { ltype = 5; str.erase( posn, 1 ); goto FINI; }
     164
     165                posn = str.find_last_of( "zZ" );                                // size_t
     166                if ( posn != string::npos ) { Unsigned = true; type = 2; ltype = 4; str.erase( posn, 1 ); goto FINI; }
     167
     168                posn = str.rfind( "hh" );                                               // char
     169                if ( posn != string::npos ) { type = 1; str.erase( posn, 2 ); goto FINI; }
     170
     171                posn = str.rfind( "HH" );                                               // char
     172                if ( posn != string::npos ) { type = 1; str.erase( posn, 2 ); goto FINI; }
     173
     174                posn = str.find_last_of( "hH" );                                // short
     175                if ( posn != string::npos ) { type = 0; str.erase( posn, 1 ); goto FINI; }
     176
     177                posn = str.find_last_of( "nN" );                                // int (natural number)
     178                if ( posn != string::npos ) { type = 2; str.erase( posn, 1 ); goto FINI; }
     179
     180                if ( str.rfind( "ll" ) != string::npos || str.rfind( "LL" ) != string::npos ) { type = 4; goto FINI; }
     181
     182                lnthSuffix( str, type, ltype );                                 // must be after check for "ll"
     183          FINI: ;
     184        } // if
     185
    141186        // Cannot be just "0"/"1"; sscanf stops at the suffix, if any; value goes over the wall => always generate
    142187
     188#if ! defined(__SIZEOF_INT128__)
     189        if ( type == 5 ) SemanticError( yylloc, "int128 constant is not supported on this target " + str );
     190#endif // ! __SIZEOF_INT128__
     191       
    143192        if ( str[0] == '0' ) {                                                          // radix character ?
    144193                dec = false;
    145194                if ( checkX( str[1] ) ) {                                               // hex constant ?
    146                         sscanf( (char *)str.c_str(), "%llx", &v );
     195                        if ( type < 5 ) {                                                       // not L128 ?
     196                                sscanf( (char *)str.c_str(), "%llx", &v );
     197                        } else {                                                                        // hex int128 constant
     198                                unsigned int len = str.length();
     199                                if ( len > (2 + 16 + 16) ) SemanticError( yylloc, "128-bit hexadecimal constant to large " + str );
     200                          if ( len <= (2 + 16) ) goto FHEX1;            // hex digits < 2^64
     201                                str2 = "0x" + str.substr( len - 16 );
     202                                sscanf( (char *)str2.c_str(), "%llx", &v2 );
     203                                str = str.substr( 0, len - 16 );
     204                          FHEX1: ;
     205                                sscanf( (char *)str.c_str(), "%llx", &v );
     206                        } // if
    147207                        //printf( "%llx %llu\n", v, v );
    148208                } else if ( checkB( str[1] ) ) {                                // binary constant ?
    149                         v = 0;                                                                          // compute value
    150                         for ( unsigned int i = 2;; ) {                          // ignore prefix
    151                                 if ( str[i] == '1' ) v |= 1;
    152                                 i += 1;
    153                           if ( i == last - 1 || (str[i] != '0' && str[i] != '1') ) break;
    154                                 v <<= 1;
    155                         } // for
     209                        unsigned int len = str.length();
     210                        if ( type == 5 && len > 2 + 64 ) {
     211                                if ( len > 2 + 64 + 64 ) SemanticError( yylloc, "128-bit binary constant to large " + str );
     212                                str2 = "0b" + str.substr( len - 64 );
     213                                str = str.substr( 0, len - 64 );
     214                                scanbin( str2, v2 );
     215                        } // if
     216                        scanbin( str, v );
    156217                        //printf( "%#llx %llu\n", v, v );
    157218                } else {                                                                                // octal constant
    158                         sscanf( (char *)str.c_str(), "%llo", &v );
     219                        if ( type < 5 ) {                                                       // not L128 ?
     220                                sscanf( (char *)str.c_str(), "%llo", &v );
     221#if defined(__SIZEOF_INT128__)
     222                        } else {                                                                        // octal int128 constant
     223                                unsigned int len = str.length();
     224                                char buf[32];
     225                                __int128 val = v;
     226                               
     227                                if ( len > 1 + 43 || (len == 1 + 43 && str[0] > '3') ) SemanticError( yylloc, "128-bit octal constant to large " + str );
     228                                if ( len <= 1 + 21 ) {                                  // value < 21 octal digitis
     229                                        sscanf( (char *)str.c_str(), "%llo", &v ); // leave value in octal
     230                                } else {
     231                                        sscanf( &str[len - 21], "%llo", &v );
     232                                        val = v;                                                        // store bits
     233                                        str[len - 21] ='\0';                            // shorten string
     234                                        sscanf( &str[len == 43 ? 1 : 0], "%llo", &v );
     235                                        val |= (__int128)v << 63;                       // store bits
     236                                        if ( len == 1 + 43 ) {                          // most significant 2 bits ?
     237                                                str[2] = '\0';                                  // shorten string
     238                                                sscanf( &str[1], "%llo", &v );  // process most significant 2 bits
     239                                                val |= (__int128)v << 126;              // store bits
     240                                        } // if
     241                                        v = val >> 64; v2 = (uint64_t)val;      // replace octal constant with 2 hex constants
     242                                        sprintf( buf, "%#llx", v2 );
     243                                        str2 = buf;
     244                                        sprintf( buf, "%#llx", v );
     245                                        str = buf;
     246                                } // if
     247#endif // __SIZEOF_INT128__
     248                        } // if
    159249                        //printf( "%#llo %llu\n", v, v );
    160250                } // if
    161251        } else {                                                                                        // decimal constant ?
    162                 sscanf( (char *)str.c_str(), "%llu", &v );
     252                if ( type < 5 ) {                                                               // not L128 ?
     253                        sscanf( (char *)str.c_str(), "%llu", &v );
     254#if defined(__SIZEOF_INT128__)
     255                } else {                                                                                // decimal int128 constant
     256                        #define P10_UINT64 10'000'000'000'000'000'000ULL // 19 zeroes
     257                        unsigned int len = str.length();
     258                        char buf[32];
     259                        __int128 val = v;
     260
     261                        if ( str.length() == 39 && str > (Unsigned ? "340282366920938463463374607431768211455" : "170141183460469231731687303715884105727") )
     262                                SemanticError( yylloc, "128-bit decimal constant to large " + str );
     263                        if ( len <= 19 ) {                                                      // value < 19 decimal digitis
     264                                sscanf( (char *)str.c_str(), "%llu", &v ); // leave value in decimal
     265                        } else {
     266                                sscanf( &str[len - 19], "%llu", &v );
     267                                val = v;                                                                // store bits
     268                                str[len - 19] ='\0';                                    // shorten string
     269                                sscanf( &str[len == 39 ? 1 : 0], "%llu", &v );
     270                                val += (__int128)v * (__int128)P10_UINT64; // store bits
     271                                if ( len == 39 ) {                                              // most significant 2 bits ?
     272                                        str[1] = '\0';                                          // shorten string
     273                                        sscanf( &str[0], "%llu", &v );          // process most significant 2 bits
     274                                        val += (__int128)v * (__int128)P10_UINT64 * (__int128)P10_UINT64; // store bits
     275                                } // if
     276                                v = val >> 64; v2 = (uint64_t)val;              // replace decimal constant with 2 hex constants
     277                                sprintf( buf, "%#llx", v2 );
     278                                str2 = buf;
     279                                sprintf( buf, "%#llx", v );
     280                                str = buf;
     281                        } // if
     282#endif // __SIZEOF_INT128__
     283                } // if
    163284                //printf( "%llu\n", v );
    164285        } // if
    165286
    166         string::size_type posn;
    167 
    168         if ( isdigit( str[last] ) ) {                                           // no suffix ?
    169                 lnthSuffix( str, type, ltype );                                 // could have length suffix
    170                 if ( type == -1 ) {                                                             // no suffix
    171                         valueToType( v, dec, type, Unsigned );
    172                 } // if
    173         } else {
    174                 // At least one digit in integer constant, so safe to backup while looking for suffix.
    175 
    176                 posn = str.find_last_of( "pP" );
    177                 if ( posn != string::npos ) { valueToType( v, dec, type, Unsigned ); ltype = 5; str.erase( posn, 1 ); goto FINI; }
    178 
    179                 posn = str.find_last_of( "zZ" );
    180                 if ( posn != string::npos ) { Unsigned = true; type = 2; ltype = 4; str.erase( posn, 1 ); goto FINI; }
    181 
    182                 // 'u' can appear before or after length suffix
    183                 if ( str.find_last_of( "uU" ) != string::npos ) Unsigned = true;
    184 
    185                 posn = str.rfind( "hh" );
    186                 if ( posn != string::npos ) { type = 1; str.erase( posn, 2 ); goto FINI; }
    187 
    188                 posn = str.rfind( "HH" );
    189                 if ( posn != string::npos ) { type = 1; str.erase( posn, 2 ); goto FINI; }
    190 
    191                 posn = str.find_last_of( "hH" );
    192                 if ( posn != string::npos ) { type = 0; str.erase( posn, 1 ); goto FINI; }
    193 
    194                 posn = str.find_last_of( "nN" );
    195                 if ( posn != string::npos ) { type = 2; str.erase( posn, 1 ); goto FINI; }
    196 
    197                 if ( str.rfind( "ll" ) != string::npos || str.rfind( "LL" ) != string::npos ) { type = 4; goto FINI; }
    198 
    199                 lnthSuffix( str, type, ltype );                                 // must be after check for "ll"
    200                 if ( type == -1 ) {                                                             // only 'u' suffix ?
    201                         valueToType( v, dec, type, Unsigned );
    202                 } // if
    203           FINI: ;
    204         } // if
     287        if ( type == -1 ) {                                                                     // no suffix => determine type from value size
     288                valueToType( v, dec, type, Unsigned );
     289        } // if
     290        /* printf( "%s %llo %s %llo\n", str.c_str(), v, str2.c_str(), v2 ); */
    205291
    206292        //if ( !( 0 <= type && type <= 6 ) ) { printf( "%s %lu %d %s\n", fred.c_str(), fred.length(), type, str.c_str() ); }
     
    214300        } else if ( ltype != -1 ) {                                                     // explicit length ?
    215301                if ( ltype == 6 ) {                                                             // int128, (int128)constant
    216                         ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][type] ), false );
     302//                      ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][type] ), false );
     303                        ret2 = new ConstantExpr( Constant( new BasicType( noQualifiers, BasicType::LongLongSignedInt ), str2, v2 ) );
     304                        ret = build_compoundLiteral( DeclarationNode::newBasicType( DeclarationNode::Int128 )->addType( DeclarationNode::newSignedNess( DeclarationNode::Unsigned ) ),
     305                                                                                 new InitializerNode( (InitializerNode *)(new InitializerNode( new ExpressionNode( v2 == 0 ? ret2 : ret ) ))->set_last( new InitializerNode( new ExpressionNode( v2 == 0 ? ret : ret2 ) ) ), true ) );
    217306                } else {                                                                                // explicit length, (length_type)constant
    218307                        ret = new CastExpr( ret, new TypeInstType( Type::Qualifiers(), lnthsInt[Unsigned][ltype], false ), false );
  • tests/.expect/manipulatorsOutput3.x64.txt

    re1801fc rf5d4f62  
    33+1208907372870555465220095
    44
     5base 2
    560b11111111111111110000000000000000000000000000000000000000000000001111111111111111
    670B11111111111111110000000000000000000000000000000000000000000000001111111111111111
     
    10110X0000000000FFFF000000000000FFFF
    1112
     130b1001011001110110101011000110010011111001100011011000100011110100000000000000000
     140B1001011001110110101011000110010011111001100011011000100011110100000000000000000
     150B1001011001110110101011000110010011111001100011011000100011110100000000000000000
     160B1001011001110110101011000110010011111001100011011000100011110100000000000000000
     170B1001011001110110101011000110010011111001100011011000100011110100000000000000000
     180B1001011001110110101011000110010011111001100011011000100011110100000000000000000
     190B1001011001110110101011000110010011111001100011011000100011110100000000000000000
     20
     21base 8
    12220000000123
    13230000000123
     
    425203777777777777777777777777777777777776543211Y
    4353
     540113166530623714330436400000
     55          0113166530623714330436400000
     56            0113166530623714330436400000
     57  00000000000113166530623714330436400000
     58          000113166530623714330436400000
     59  00000000000113166530623714330436400000
     60
     61base 10
     62355272055279601493606400
     63355272055279601493606400
     64355272055279601493606400
     65355272055279601493606400
     66355272055279601493606400
     67              355272055279601493606400
     68               355272055279601493606400
     69                355272055279601493606400
     70          000000355272055279601493606400
     71  00000000000000355272055279601493606400
     720000000000000000355272055279601493606400
     730000000000000000355272055279601493606400
     74+000000000000000355272055279601493606400
     75
     76base 16
    44770xffff000000000000ffff
    45780XFFFF000000000000FFFF
     
    52850X00000000000000000000000000000FFFF000000000000FFFFX
    5386
    54 base 2
    55 0b1001011001110110101011000110010011111001100011011000100011110100000000000000000
    56 0B1001011001110110101011000110010011111001100011011000100011110100000000000000000
    57 0B1001011001110110101011000110010011111001100011011000100011110100000000000000000
    58 0B1001011001110110101011000110010011111001100011011000100011110100000000000000000
    59 0B1001011001110110101011000110010011111001100011011000100011110100000000000000000
    60 0B1001011001110110101011000110010011111001100011011000100011110100000000000000000
    61 0B1001011001110110101011000110010011111001100011011000100011110100000000000000000
    62 
    63 base 8
    64 0113166530623714330436400000
    65           0113166530623714330436400000
    66             0113166530623714330436400000
    67   00000000000113166530623714330436400000
    68           000113166530623714330436400000
    69   00000000000113166530623714330436400000
    70 
    71 base 10
    72 355272055279601493606400
    73 355272055279601493606400
    74 355272055279601493606400
    75 355272055279601493606400
    76 355272055279601493606400
    77               355272055279601493606400
    78                355272055279601493606400
    79                 355272055279601493606400
    80           000000355272055279601493606400
    81   00000000000000355272055279601493606400
    82 0000000000000000355272055279601493606400
    83 0000000000000000355272055279601493606400
    84 +000000000000000355272055279601493606400
    85 
    86 base 16
    87870X4B3B56327CC6C47A0000
    8888                0X4B3B56327CC6C47A0000
     
    108108+0000000000000000355272055279601493606400X
    109109+0000000000000000000000000000000123456789X
     110-1000 0xfffffffffffffffffffffffffffffc18 03777777777777777777777777777777777777776030
     1110b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000011000
     112-999 0xfffffffffffffffffffffffffffffc19 03777777777777777777777777777777777777776031
     1130b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000011001
     114-998 0xfffffffffffffffffffffffffffffc1a 03777777777777777777777777777777777777776032
     1150b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000011010
     116-997 0xfffffffffffffffffffffffffffffc1b 03777777777777777777777777777777777777776033
     1170b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000011011
     118-996 0xfffffffffffffffffffffffffffffc1c 03777777777777777777777777777777777777776034
     1190b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000011100
     120-995 0xfffffffffffffffffffffffffffffc1d 03777777777777777777777777777777777777776035
     1210b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000011101
     122-994 0xfffffffffffffffffffffffffffffc1e 03777777777777777777777777777777777777776036
     1230b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000011110
     124-993 0xfffffffffffffffffffffffffffffc1f 03777777777777777777777777777777777777776037
     1250b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000011111
     126-992 0xfffffffffffffffffffffffffffffc20 03777777777777777777777777777777777777776040
     1270b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000100000
     128-991 0xfffffffffffffffffffffffffffffc21 03777777777777777777777777777777777777776041
     1290b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000100001
     130
     131
     132-990                                                                                                                                                           
     133-990
     1340xfffffffffffffffffffffffffffffc22
     13503777777777777777777777777777777777777776042
     1360b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000100010
     137-990
     1380xfffffffffffffffffffffffffffffc22
     13903777777777777777777777777777777777777776042
     1400b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000100010
     141-990                           
     1420xfffffffffffffffffffffffffffffc22
     14303777777777777777777777777777777777777776042
     1440b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000100010
     145-990                                                                                                                                                           
     1460xfffffffffffffffffffffffffffffc22                                                                                                                             
     14703777777777777777777777777777777777777776042                                                                                                                   
     1480b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000100010                             
     149-990                                                                                                                                                           
     1500XFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC22                                                                                                                             
     15103777777777777777777777777777777777777776042                                                                                                                   
     1520B11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000100010                             
     15322763282186957586699822X
     154                   04644000000000000000013056X
     15504644000000000000000013056                   X
     156                   04644000000000000000013056X
     15704644000000000000000013056                   X
     158                   04644000000000000000013056X
     15904644000000000000000013056                   X
     160         000000000004644000000000000000013056X
     161000000000004644000000000000000013056         X
     1620000000000000000000004644000000000000000013056X
     1630000000000000000000004644000000000000000013056X
     16404644000000000000000013056                   X
     16504644000000000000000013056                   X
     16604644000000000000000013056                   X
     16704644000000000000000013056                   X
     1680004644000000000000000013056                 X
     16903777777777777777773133777777777777777764722Y
     17003777777777777777773133777777777777777764722Y
     17103777777777777777773133777777777777777764722Y
     17203777777777777777773133777777777777777764722Y
     17303777777777777777773133777777777777777764722Y
     17403777777777777777773133777777777777777764722Y
     17503777777777777777773133777777777777777764722 Y
     1760000003777777777777777773133777777777777777764722Y
     17703777777777777777773133777777777777777764722 Y
     1780123                                         X
     17904644000000000000000013056                   X
     1800000000000000000000000000000000000000123     X
     1810000000000000004644000000000000000013056     X
     182000000000000000000000000000000000000000000123X
     183000000000000000000004644000000000000000013056X
     1840000000123                              X
     18504644000000000000000013056              X
     18603777777777777777773133777777777777777764722X
     1870000000000000000000000000000000000000123X
     1880000000000000004644000000000000000013056X
     18903777777777777777773133777777777777777764722X
     1901777777777777777777777
     1912777777777777777777777
     1923777777777777777777777
     1934777777777777777777777
     1945777777777777777777777
     1956777777777777777777777
     1967777777777777777777777
     19710777777777777777777777
     1980b11111111111111110000000000000000000000000000000000000000000000001111111111111111
     1990B11111111111111110000000000000000000000000000000000000000000000001111111111111111
     20011111111111111110000000000000000000000000000000000000000000000001111111111111111
     201             0B11111111111111110000000000000000000000000000000000000000000000001111111111111111
     202   0B000000000011111111111111110000000000000000000000000000000000000000000000001111111111111111
     2030B00000000000000011111111111111110000000000000000000000000000000000000000000000001111111111111111
     2040b11111111111111110000000000000000000000000000000000000000000000001111111111111111
     2050B11111111111111110000000000000000000000000000000000000000000000001111111111111111
     20611111111111111110000000000000000000000000000000000000000000000001111111111111111
     2070B11111111111111110000000000000000000000000000000000000000000000001111111111111111             
     2080B000000000011111111111111110000000000000000000000000000000000000000000000001111111111111111   
     2090B011111111111111110000000000000000000000000000000000000000000000001111111111111111           
     2100B11111111111111110000000000000000000000000000000000000000000000001111111111111111             
     2110B11111111111111110000000000000000000000000000000000000000000000001111111111111111             
     2120B000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111   
     2130B0000000000000000000000000000000000000000000000001111111111111111 
     2140B00000000000000011111111111111110000000000000000000000000000000000000000000000001111111111111111
     215   0X000000000000000000000FFFF
     216   0X000000000000000000000FFFF
     2170X00000000000000000000000000FFFF
     2180X00000000000000000000000000FFFF
     21905000000000000000000123
     220                      05000000000000000000123
     22105000000000000000000123                      X
     2220000000123                              X
     2230377776000000000000000177777            X
     22405000000000000000000123                 X
     2250000000000000000000000000000000000000123X
     2260000000000000377776000000000000000177777X
     2270000000000000000005000000000000000000123X
    110228-10                  0xfffffffffffffffffffffffffffffff6 03777777777777777777777777777777777777777766
    1112290b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110110
     
    26137912
    26238013
     3810xfffffffffffffffffffe
     3820xfffffffffffffffffffe
     383
     384binary
     3850b11111111111111111111111111111111111111111111111111111111111111111111111111111110
     3860b11111111111111111111111111111111
     3870b1111111111111111111111111111111111111111111111111111111111111111
     3880b111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
     3890b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
     3900xa2345678
     3910xa2345678a7654321
     3920xa2345678a7654321c2345678
     3930xa2345678a7654321c2345678d7554321
     394
     395octal
     3960377777777777777777777777776
     3970123456
     398012345665432
     39901234566543234567
     4000123456654323456776543
     401012345665432345677654323456
     40201234566543234567765432345665432
     4030123456654323456776543234566543234567
     404012345665432345677654323456654323456776543
     40501111111111111111111
     406011111111111111111111
     4070111111111111111111111
     408
     409decimal
     4101208925819614629174706174
     41142798 0123456
     4121402432282 012345665432
     41345954901031287 01234566543234567
     4141505850196993244515 0123456654323456776543
     415394749758663249135511342 0123456665432345677654323456
     41612935154696204706112391834394 012345665432234567765432345665432
     417423859149128410414395372834994551 01234566543234567776543234566543234567
     41813889016598639747063234935497057631587 0123456654323456776543323456654323456776543
     4191234567890123456789
     4201234567890123456789
     421170141183460469231731687303715884105727
     422340282366920938463463374607431768211455
     4239223372036854775808
     424340282366920938463463374607431768211455
     425170141183460469231731687303715884105727
     426
     427hexadecimal
     4280xfffffffffffffffffffe
     4290xffffffff
     4300xffffffffffffffff
     4310xffffffffffffffffffffffff
     4320xffffffffffffffffffffffffffffffff
     4330xa2345678
     4340xa2345678b7654321
     4350xa2345678b7654321c2345678
     4360xa2345678b7654321c2345678d7654321
     437
  • tests/manipulatorsOutput3.cfa

    re1801fc rf5d4f62  
    11#include <fstream.hfa>
     2
    23int 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 }
     4        // int128 printing
     5        int128 x = 0xffff, y = 0x2;
     6
     7        x <<= 64;
     8        x += 0xffff;
     9        y <<= 64;
     10        y += 0123;
     11        y |= 0x8000000000000000;
     12        x = -x;
     13        sout | x;
     14        sout | sign(x);
     15        x = -x;
     16        sout | sign(x);
     17        sout | nl;
     18
     19        int128 divisor = 0x4b3b4ca85a86c47a;
     20        divisor <<= 16;
     21        divisor += 0x98a224000000000;
     22       
     23        // base 2
     24        sout | "base 2";
     25        sout | bin(x);
     26        sout | upcase(bin(x));
     27        sout | nobase(bin(x));
     28        sout | wd( 95, upcase(bin(x)) );
     29        sout | wd( 95,90, upcase(bin(x)) );
     30        sout | wd( 25,30, upcase(hex(x)) );
     31        sout | nl;
     32
     33        sout | bin(divisor);
     34        sout | upcase(bin(divisor));
     35        sout | wd(38, upcase(bin(divisor)));
     36        sout | wd(40, upcase(bin(divisor)));
     37        sout | wd(40, 38, upcase(bin(divisor)));
     38        sout | wd(40, 30, upcase(bin(divisor)));
     39        sout | pad0(sign(wd(40, 38, upcase(bin(divisor)))));
     40        sout | nl;
     41       
     42        // oct
     43        sout | "base 8";
     44        printf( "%#.10o\n", 0123 );
     45        sout | wd( 1,10, oct(0123) );
     46        sout | oct(x);
     47        sout | nobase(oct(x));
     48        sout | wd( 45, oct(0123) );
     49        sout | wd( 45,40, oct(0123) );
     50        sout | wd( 40,45, oct(0123) );
     51        sout | wd( 45, oct(x) );
     52        sout | wd( 45,40, oct(x) );
     53        sout | wd( 40,45, oct(x) );
     54
     55        sout | left(wd( 45, oct(0123) )) | 'X';
     56        sout | left(wd( 45, oct(x) )) | 'X';
     57        sout | left(wd( 45, oct(y) )) | 'X';
     58        sout | left(wd( 45,40, oct(0123) )) | 'X';
     59        sout | left(wd( 45,40, oct(x) )) | 'X';
     60        sout | left(wd( 45,40, oct(y) )) | 'X';
     61        sout | left(wd( 40,45, oct(0123) )) | 'X';
     62        sout | left(wd( 40,45, oct(x) )) | 'X';
     63        sout | left(wd( 40,45, oct(y) )) | 'X';
     64        printf( "%#-1.10oX\n", 0123 );
     65        sout | left(wd( 1,10, oct(0123) )) | 'X';
     66        printf( "%#-40.10oX\n", 0123 );
     67        sout | left(wd( 40,10, oct(0123) )) | 'X';
     68        sout | left(wd( 40,10, oct(x) )) | 'X';
     69        sout | left(wd( 40,10, oct(y) )) | 'X';
     70        sout | left(wd( 10,40, oct(0123) )) | 'X';
     71        sout | left(wd( 10,40, oct(x) )) | 'X';
     72        sout | left(wd( 10,40, oct(y) )) | 'X';
     73
     74        y = 01234567;
     75        sout | left(wd( 45, 49, oct(y) )) | 'X';
     76        y = -y;
     77        sout | wd(0, oct(y)) | 'Y';
     78        sout | left(wd(0, oct(y))) | 'Y';
     79        sout | nl;
     80
     81        sout | upcase(oct(divisor));
     82        sout | wd(38, upcase(oct(divisor)));
     83        sout | wd(40, upcase(oct(divisor)));
     84        sout | wd(40, 38, upcase(oct(divisor)));
     85        sout | wd(40, 30, upcase(oct(divisor)));
     86        sout | pad0(sign(wd(40, 38, upcase(oct(divisor)))));
     87        sout | nl;
     88
     89        // decimal
     90        sout | "base 10";
     91        sout | divisor;
     92        sout | wd(2, divisor);
     93        sout | wd(3, divisor);
     94        sout | wd(10, divisor);
     95        sout | wd(24, divisor);
     96        sout | wd(38, divisor);
     97        sout | wd(39, divisor);
     98        sout | wd(40, divisor);
     99       
     100        sout | wd(40, 30, divisor);
     101        sout | wd(40, 38, divisor);
     102        sout | wd(40, 40, divisor);
     103        sout | pad0(wd(40, divisor));
     104        sout | pad0(sign(wd(40,divisor)));
     105        sout | nl;
     106       
     107        // hex
     108        sout | "base 16";
     109
     110        sout | hex(x);
     111        sout | upcase(hex(x));
     112        sout | nobase(hex(x));
     113        sout | wd( 45, upcase(hex(x)) );
     114        sout | wd( 45,40, upcase(hex(x)) );
     115        sout | wd( 45,49, upcase(hex(x)) );
     116        sout | left(wd( 45, upcase(hex(x)) )) | 'X';
     117        sout | left(wd( 45,40, upcase(hex(x)) )) | 'X';
     118        sout | left(wd( 45,49, upcase(hex(x)) )) | 'X';
     119        sout | nl;
     120
     121        sout | upcase(hex(divisor));
     122        sout | wd(38, upcase(hex(divisor)));
     123        sout | wd(40, upcase(hex(divisor)));
     124        sout | wd(40, 38, upcase(hex(divisor)));
     125        sout | wd(40, 30, upcase(hex(divisor)));
     126        sout | pad0(sign(wd(40, 38, upcase(hex(divisor)))));
     127        sout | nl;
     128
     129        // extras
     130        sout | "extras";
     131        sout | bin(divisor);
     132        sout | upcase(bin(divisor));
     133        sout | oct(divisor);
     134        sout | hex(divisor);
     135        sout | upcase(hex(divisor));
     136        sout | nobase(bin(divisor)) | nobase(oct(divisor)) | nobase(hex(divisor));
     137        sout | sign(divisor);
     138        sout | -divisor;
     139        sout | sign(-divisor);
     140        sout | wd(2, divisor);
     141        sout | wd(3,10,divisor);
     142        sout | left(wd(40,divisor)) | 'X';
     143        sout | left(sign(wd(40, divisor))) | 'X';
     144        sout | left(sign(wd(0,40, divisor))) | 'X';
     145        printf( "%-+1.40dX\n", 123456789 );
     146
     147        int128 i128;
     148        unsigned int128 ui128;
     149        i128 = -1000;
     150        for ( 10 ) {
     151                sout | left( sign( wd( 2, i128 ) ) ) | left( wd( 2, hex( i128 ) ) ) | left( wd( 2, oct( i128 ) ) );
     152                sout | left( wd( 2, bin( i128 ) ) );
     153                i128 += 1;
     154        }
     155        sout | nl;
     156        sout | nl;
     157
     158        ui128 = 0x7fffffffffffffff;
     159        ui128 <<= 64;
     160        ui128 += 0xffffffffffffffff;
     161        sout | left( wd( 160, i128 ) );
     162        sout | left( sign( wd( 0, i128 ) ) );
     163        sout | left( wd( 0, hex( i128 ) ) );
     164        sout | left( wd( 0, oct( i128 ) ) );
     165        sout | left( wd( 0, bin( i128 ) ) );
     166        sout | left( sign( wd( 1, i128 ) ) );
     167        sout | left( wd( 1, hex( i128 ) ) );
     168        sout | left( wd( 1, oct( i128 ) ) );
     169        sout | left( wd( 1, bin( i128 ) ) );
     170        sout | left( sign( wd( 32, i128 ) ) );
     171        sout | left( wd( 32, hex( i128 ) ) );
     172        sout | left( wd( 32, oct( i128 ) ) );
     173        sout | left( wd( 32, bin( i128 ) ) );
     174        sout | left( sign( wd( 160, i128 ) ) );
     175        sout | left( wd( 160, hex( i128 ) ) );
     176        sout | left( wd( 160, oct( i128 ) ) );
     177        sout | left( wd( 160, bin( i128 ) ) );
     178        sout | left( sign( wd( 160, i128 ) ) );
     179        sout | left( wd( 160, upcase(hex( i128 )) ) );
     180        sout | left( wd( 160, upcase(oct( i128 ) )) );
     181        sout | left( wd( 160, upcase(bin( i128 )) ) );
     182
     183        x = 1234;
     184        x <<= 64;
     185        x += 5678;
     186        sout | x | 'X';
     187        sout | wd(45, 20, oct(x)) | 'X';
     188        sout | left(wd(45, 20, oct(x))) | 'X';
     189        sout | wd(45, 21, oct(x)) | 'X';
     190        sout | left(wd(45, 21, oct(x))) | 'X';
     191        sout | wd(45, 22, oct(x)) | 'X';
     192        sout | left(wd(45, 22, oct(x))) | 'X';
     193        sout | wd(45, 36, oct(x)) | 'X';
     194        sout | left(wd(45, 36, oct(x))) | 'X';
     195        sout | wd(45, 46, oct(x)) | 'X';
     196        sout | left(wd(45, 46, oct(x))) | 'X';
     197        sout | left(wd(45, 20, oct(x))) | 'X';
     198        sout | left(wd(45, 22, oct(x))) | 'X';
     199        sout | left(wd(45, 24, oct(x))) | 'X';
     200        sout | left(wd(45, 26, oct(x))) | 'X';
     201        sout | left(wd(45, 28, oct(x))) | 'X';
     202
     203        y = -x;
     204        sout | oct(y) | 'Y';
     205        sout | left(wd(0, oct(y))) | 'Y';
     206        sout | left(wd(20, oct(y))) | 'Y';
     207        sout | left(wd(26, oct(y))) | 'Y';
     208        sout | left(wd(40, oct(y))) | 'Y';
     209        sout | left(wd(41, oct(y))) | 'Y';
     210        sout | left(wd(45, oct(y))) | 'Y';
     211        sout | left(wd(45, 49, oct(y))) | 'Y';
     212        sout | left(wd(45, 4, oct(y))) | 'Y';
     213        sout | left(wd( 45, oct(0123) )) | 'X';
     214        sout | left(wd( 45, oct(x) )) | 'X';
     215        sout | left(wd( 45,40, oct(0123) )) | 'X';
     216        sout | left(wd( 45,40, oct(x) )) | 'X';
     217        sout | left(wd( 40,45, oct(0123) )) | 'X';
     218        sout | left(wd( 40,45, oct(x) )) | 'X';
     219        sout | left(wd( 40,10, oct(0123) )) | 'X';
     220        sout | left(wd( 40,10, oct(x) )) | 'X';
     221        sout | left(wd( 40,10, oct(y) )) | 'X';
     222        sout | left(wd( 10,40, oct(0123) )) | 'X';
     223        sout | left(wd( 10,40, oct(x) )) | 'X';
     224        sout | left(wd( 10,40, oct(y) )) | 'X';
     225
     226        x = 0xffff, y = 0x2;
     227        int128 z = 0x_ffff_ffff_ffff_ffff;
     228        x <<= 64;
     229        x += 0xffff;
     230        y <<= 64;
     231        y += 0123;
     232        y |= 0x8000000000000000;
     233
     234        for ( int128 i = 0; i < 8; i += 1 ) {
     235                sout | nobase(oct(z + 0x8000000000000000 * i));
     236        } // for
     237
     238        sout | bin(x);
     239        sout | upcase(bin(x));
     240        sout | nobase(bin(x));
     241
     242        sout | wd( 95, upcase(bin(x)) );
     243        sout | wd( 95,90, upcase(bin(x)) );
     244        sout | wd( 90,95, upcase(bin(x)) );
     245
     246        sout | left(bin(x));
     247        sout | left(upcase(bin(x)));
     248        sout | left(nobase(bin(x)));
     249
     250        sout | left(wd( 95, upcase(bin(x)) ));
     251        sout | left(wd( 95,90, upcase(bin(x)) ));
     252        sout | left(wd( 95,81, upcase(bin(x)) ));
     253
     254        sout | left(wd( 95,80, upcase(bin(x)) ));
     255        sout | left(wd( 95,79, upcase(bin(x)) ));
     256        sout | left(wd( 95,90, upcase(bin(0xffff)) ));
     257
     258        sout | left(wd( 68,64, upcase(bin(0xffff)) ));
     259        sout | left(wd( 90,95, upcase(bin(x)) ));
     260
     261        printf( "%#30.25X\n", 0xffff );
     262        sout | wd( 30,25, upcase(hex(0xffff)) );
     263        printf( "%#25.30X\n", 0xffff );
     264        sout | wd( 25,30, upcase(hex(0xffff)) );
     265
     266        sout | oct(y);
     267        sout | wd( 45, oct(y) );
     268        sout | left(wd( 45, oct(y) )) | 'X';
     269
     270        sout | left(wd( 40,10, oct(0123) )) | 'X';
     271        sout | left(wd( 40,10, oct(x) )) | 'X';
     272        sout | left(wd( 40,10, oct(y) )) | 'X';
     273        sout | left(wd( 10,40, oct(0123) )) | 'X';
     274        sout | left(wd( 10,40, oct(x) )) | 'X';
     275        sout | left(wd( 10,40, oct(y) )) | 'X';
     276
     277        i128 = -10;
     278        for ( 25 ) {
     279                sout | left( sign( wd( 20, i128 ) ) ) | left( wd( 20, hex( i128 ) ) ) | left( wd( 20, oct( i128 ) ) );
     280                sout | left( wd( 20, bin( i128 ) ) );
     281                i128 += 1;
     282        } // for
     283        sout | nl;
     284
     285        i128 = 0x7fffffffffffffff;
     286        i128 <<= 64;
     287        i128 += 0xfffffffffffffffa;
     288
     289//      for ( 20 ) {
     290        volatile int stop = 20;                                                         // gcc compiler bug
     291        for ( int i = 0; i < stop; i += 1 ) {
     292                sout | i128;
     293                sout | left( sign( wd( 45, i128 ) ) ) | left( wd( 45, hex( i128 ) ) ) | left( wd( 45, oct( i128 ) ) );
     294                sout | left( wd( 45, bin( i128 ) ) );
     295                i128 += 1;
     296        } // for
     297        sout | nl;
     298
     299        ui128 = 0x7fffffffffffffff;
     300        ui128 <<= 64;
     301        ui128 += 0xfffffffffffffffa;
     302       
     303        for ( 20 ) {
     304                sout | ui128;
     305                ui128 += 1;
     306        }
     307        sout | nl;
     308
     309        ui128 = 0xffffffffffffffff;
     310        ui128 <<= 64;
     311        ui128 += 0xfffffffffffffffa;
     312       
     313        for ( 20 ) {
     314                sout | ui128;
     315                ui128 += 1;
     316        }
     317
     318
     319        // int128 constants (and printing)
     320        int128 v = 0xffff_ffffffff_ffffffff_L128 + 0xffffffff_ffffffff_ffffffff_ffffffff_L128;
     321        sout | hex(v);
     322        v = 0xffff_ffffffff_ffffffff_L128 + 0xffffffff_ffffffff_ffffffff_ffffffff_L128;
     323        sout | hex(v);
     324        sout | nl;
     325
     326        sout | "binary";
     327        sout | bin(v);
     328        sout | bin(0b_11111111111111111111111111111111_L128);
     329        sout | bin(0b_11111111111111111111111111111111_11111111111111111111111111111111_L128);
     330        sout | bin(0b_11111111111111111111111111111111_11111111111111111111111111111111_11111111111111111111111111111111_L128);
     331        sout | bin(0b_11111111111111111111111111111111_11111111111111111111111111111111_11111111111111111111111111111111_11111111111111111111111111111111_L128);
     332        sout | hex(0b_10100010001101000101011001111000_L128);
     333        sout | hex(0b_10100010001101000101011001111000_10100111011001010100001100100001_L128);
     334        sout | hex(0b_10100010001101000101011001111000_10100111011001010100001100100001_11000010001101000101011001111000_L128);
     335        sout | hex(0b_10100010001101000101011001111000_10100111011001010100001100100001_11000010001101000101011001111000_11010111010101010100001100100001_L128);
     336        sout | nl;
     337
     338        sout | "octal";
     339        sout | oct(v);
     340        sout | oct(0_123456_L128u);
     341        sout | oct(0_123456_65432_uL128);
     342        sout | oct(0_123456_65432_34567_L128);
     343        sout | oct(0_123456_65432_34567_76543_L128);
     344        sout | oct(0_123456_65432_34567_76543_23456_L128);
     345        sout | oct(0_123456_65432_34567_76543_23456_65432_L128);
     346        sout | oct(0_123456_65432_34567_76543_23456_65432_34567_L128);
     347        sout | oct(0_123456_65432_34567_76543_23456_65432_34567_76543_L128);
     348        sout | oct(0_1111111111111111111L);
     349        sout | oct(0_11111111111111111111L);
     350        sout | oct(0_111111111111111111111L);
     351        sout | nl;
     352
     353        sout | "decimal";
     354        sout | v;
     355        sout | 42_798_L128 | oct(42_798_L128);
     356        sout | 1_402_432_282_L128 | oct(1_402_432_282_L128);
     357        sout | 45_954_901_031_287_L128 | oct(45_954_901_031_287_L128);
     358        sout | 1_505_850_196_993_244_515_L128 | oct(1_505_850_196_993_244_515_L128);
     359        sout | 394_749_758_663_249_135_511_342_L128 | oct(394_749_758_663_249_135_511_342_L128);
     360        sout | 12_935_154_696_204_706_112_391_834_394_L128 | oct(12_935_154_696_204_706_112_391_834_394_L128);
     361        sout | 423_859_149_128_410_414_395_372_834_994_551_L128 | oct(423_859_149_128_410_414_395_372_834_994_551_L128);
     362        sout | 13_889_016_598_639_747_063_234_935_497_057_631_587_L128 | oct(13_889_016_598_639_747_063_234_935_497_057_631_587_L128);
     363        sout | 1234567890123456789_uL128;
     364        sout | 1234567890123456789_L128u;
     365        sout | 0x_7fffffff_ffffffff_ffffffff_ffffffff_L128;
     366        sout | 0x_ffffffff_ffffffff_ffffffff_ffffffff_L128;
     367        sout | 0x_80000000_00000000_00000000_00000000_L128;
     368        unsigned int128 vv;
     369        vv = 340282366920938463463374607431768211455_L128u;
     370        sout | vv;
     371        vv = 170141183460469231731687303715884105727_L128;
     372        sout | vv;
     373        sout | nl;
     374
     375        sout | "hexadecimal";
     376        sout | hex(v);
     377        sout | hex(0x_ffffffff_L128);
     378        sout | hex(0x_ffffffff_ffffffff_L128);
     379        sout | hex(0x_ffffffff_ffffffff_ffffffff_L128);
     380        sout | hex(0xffffffff_ffffffff_ffffffff_ffffffff_L128);
     381        sout | hex(0x_a2345678_L128);
     382        sout | hex(0x_a2345678_b7654321_L128);
     383        sout | hex(0x_a2345678_b7654321_c2345678_L128);
     384        sout | hex(0x_a2345678_b7654321_c2345678_d7654321_L128);
     385        sout | nl;
     386} // main
     387
     388// Local Variables: //
     389// tab-width: 4 //
     390// compile-command: "cfa -Wall -Wextra manipulatorsOutput3.cfa" //
     391// End: //
Note: See TracChangeset for help on using the changeset viewer.