Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
print __int64 via ostream cout
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Andre Folkers  
View profile  
 More options Aug 24 1998, 3:00 am
Newsgroups: microsoft.public.vc.language
From: Andre Folkers <folk...@informatik.mu-luebeck.de>
Date: 1998/08/24
Subject: print __int64 via ostream cout
Hi !

I don't get an __int64 value print on standard output with the cout
stream!

I tried the following:

#include <iostream>
using namespace std;
void main()
{
  __int64 intvalue=0xffffffffffffffff;
  cout << intvalue << endl;
  return;

}

And I got the following error-message from msvc5.0:

R:\stl-test\msvcstl.cpp(38) : error C2593: 'operator <<' is ambiguous

Does anyone know, if there is a solution with ostreams. I already know
the printf-solution with %I64 option!

Thanks in advance!

Andre Folkers


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Dodds  
View profile  
 More options Aug 24 1998, 3:00 am
Newsgroups: microsoft.public.vc.language
From: "Jonathan Dodds" <do...@amsa.com>
Date: 1998/08/24
Subject: Re: print __int64 via ostream cout
As the underscores in the name should tell you, __int64 is a non-standard
type. Unlike the other __int* types __int64 is not a synonym for a standard
type.

You will probably need to write your own stream inserter for __int64 using
sprintf.

Andre Folkers wrote in message

<35E17C3C.4C79B...@informatik.mu-luebeck.de>...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrew Tucker  
View profile  
 More options Aug 24 1998, 3:00 am
Newsgroups: microsoft.public.vc.language
From: a...@halcyon.com (Andrew Tucker)
Date: 1998/08/24
Subject: Re: print __int64 via ostream cout

Here's the implementation I use:

/*
        This function is necessary to overcome the fact that an
        ostream operator<< is not supplied for the built in type
        __int64.
*/
template <class _E, class _Tr>
inline  basic_ostream<_E, _Tr>& __cdecl operator<<(     basic_ostream<_E, _Tr>& _O, __int64 i64Val)
{
        wchar_t wchBuf[32];

        // VC5BUG: _i64tow cannot handle negative numbers
        if (i64Val < 0)
        {
                _O << _U("-");
                i64Val *= -1;
        }

        return (_O << _i64tow(i64Val, wchBuf, 10)) ;      

}
Jonathan Dodds (do...@amsa.com) wrote:

: As the underscores in the name should tell you, __int64 is a non-standard
: type. Unlike the other __int* types __int64 is not a synonym for a standard
: type.
:
: You will probably need to write your own stream inserter for __int64 using
: sprintf.
:
: Andre Folkers wrote in message

: <35E17C3C.4C79B...@informatik.mu-luebeck.de>...
: >Hi !
: >
: >I don't get an __int64 value print on standard output with the cout
: >stream!
: >
: >I tried the following:
: >
: >#include <iostream>
: >using namespace std;
: >void main()
: >{
: >  __int64 intvalue=0xffffffffffffffff;
: >  cout << intvalue << endl;
: >  return;
: >}
: >
: >And I got the following error-message from msvc5.0:
: >
: >R:\stl-test\msvcstl.cpp(38) : error C2593: 'operator <<' is ambiguous
: >
: >Does anyone know, if there is a solution with ostreams. I already know
: >the printf-solution with %I64 option!
: >
: >Thanks in advance!
: >
: >Andre Folkers
: >
: >
:
:

--
--
/*  Andrew  */
WWW: http://www.halcyon.com/ast        
Email: a...@halcyon.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrew T. Brown  
View profile  
 More options Aug 24 1998, 3:00 am
Newsgroups: microsoft.public.vc.language
From: "Andrew T. Brown" <andrewbr...@acm.org>
Date: 1998/08/24
Subject: Re: print __int64 via ostream cout

This was discussed as a "Bug of the Month" in Windows Developer's Journal a
few months back.  It provided a code snippet to provide __int64 support.

(Aside: I could quibble with labeling this issue a "bug"... I don't see why
one should assume that standard library support will be extended to
non-standard types; but certainly users will notice it...)

// -----------------------------------------------------------------------
// andrew todd brown
// mailto:andrewbr...@acm.org
// -----------------------------------------------------------------------

Andre Folkers wrote in message

<35E17C3C.4C79B...@informatik.mu-luebeck.de>...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »