Example #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 );
}
Example #2
0
ostream &ostream::operator << ( signed __int64 i ) {
/**************************************************/
// Write a signed long integer to the stream.

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

    __lock_it( __i_lock );
    base = __FlagsToBase( flags() );
    if( base != 10 ) {
        return( *this << (unsigned __int64) i );
    }

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

    // Digits:
    lltoa( i, buffer + digit_offset, base );
    if( buffer[0] == '-' ) {
        digit_offset = 1;
    }
    size = ::strlen( buffer );

    // Write the number:
    if( opfx() ) {
        setstate( __WATCOM_ios::writeitem( *this, buffer, size, digit_offset ) );
        osfx();
    }
    return( *this );
}
Example #3
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 );
  }