Exemplo n.º 1
0
ostream &ostream::operator << ( unsigned __int64 i ) {
    /****************************************************/
// Write an unsigned 64bit integer to the stream.
// A signed 64bit integer displayed in base 8 or base 16 also uses
// this routine.

    int         base;
    char        buffer[LONGEST_INT64 + 1];
    int         size;
    int         digit_offset;

    __lock_it( __i_lock );
    base = __FlagsToBase( flags() );

    // Sign:
    if( i > 0  &&  (flags() & ios::showpos)  &&  base == 10 ) {
        buffer[0] = '+';
        size      = 1;
    } else {
        size      = 0;
    }

    // Prefix:
    __AddPrefix( i == 0, buffer, size, base, flags() );

    // Digits:
    digit_offset = size;
    ulltoa( i, buffer + digit_offset, base );
    if( flags() & ios::uppercase ) {
        strupr( buffer );
    }
    size = ::strlen( buffer );

    // Write the number:
    if( opfx() ) {
        setstate( __WATCOM_ios::writeitem( *this, buffer, size, digit_offset ) );
        osfx();
    }
    return( *this );
}
Exemplo n.º 2
0
  ostream &ostream::operator << ( unsigned long i ) {

    int         base;
    char        buffer[LONGEST_INTEGER + 1];
    int         size;
    int         digit_offset;

    __lock_it( __i_lock );
    base = __FlagsToBase( flags() );

    // Sign:
    if( i > 0  &&  (flags() & ios::showpos)  &&  base == 10 ) {
        buffer[0] = '+';
        size      = 1;
    } else {
        size      = 0;
    }

    // Prefix:
    __AddPrefix( i == 0, buffer, size, base, flags() );

    // Digits:
    digit_offset = size;
    ultoa( i, buffer + digit_offset, base );
    if( flags() & ios::uppercase ) {
        strupr( buffer );
    }
    size = strlen( buffer );

    // Write the number:
    if( opfx() ) {
        setstate( __WATCOM_ios::writeitem( *this, buffer, size, digit_offset ) );
        osfx();
    }
    return( *this );
  }