473,387 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Converting 64-bit interger to character

I'm trying to convert a 64-bit inter to a character string, and
failing. I don't understand the error.

here's the code:

__int64 num = 123456789012;
std::ostringstream buffer;
buffer << num;

std::string formatted = buffer.str();

The error message points at the third line and says: operator << is
ambiguous. Huh??

--
Tim Slattery
Sl********@bls.gov
http://members.cox.net/slatteryt
Jan 5 '07 #1
2 3565
"Tim Slattery" <Sl********@bls.govwrote in message
news:dc********************************@4ax.com...
I'm trying to convert a 64-bit inter to a character string, and
failing. I don't understand the error.

here's the code:

__int64 num = 123456789012;
std::ostringstream buffer;
buffer << num;

std::string formatted = buffer.str();

The error message points at the third line and says: operator << is
ambiguous. Huh??
Apparently your compiler doesn't define an operator<< for an ostringstream
for 16 bit unsigned ints.

However, your compiler usually tells you the choices it has after the error
message (along the lines of, operator<<( ostringbuffer, int ) or
operator<<( ostringbuffer, unsigned int ), etc...

Go through those choices and see if you have anything that's 64 bit. You
might be lucky and maybe they have 64 bit unsigned ints, in that case either
change it to unsigned 64 bit int or cast it in the << statment.
Jan 5 '07 #2
Tim Slattery wrote:
I'm trying to convert a 64-bit inter to a character string, and
failing. I don't understand the error.

here's the code:

__int64 num = 123456789012;
In addition to what Jim said above, 123456789012 as you have written it
is an int literal, yet too large to fit in a (32-bit) int. So you may
get a warning and/or unexpected results. gcc would let you write
123456789012LL to indicate a 64-bit literal. MSVC might let you use the
same syntax, or there might be something similar - I forget.

Jan 6 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Chris Online | last post by:
Hi all, I'm using C++ Builder5. I want to get data from an edit-box and send it to a development kit. The dev-kit can only receive char and no char* here's a part of my code: char* Data_byte...
7
by: Jus! | last post by:
Hi. I am reading bits(1's & 0's) from a file and i wa wondering what is the most efficient method of converting these strings to individual int's? eg. File contains: 110001 010011 etc......
8
by: Ramiro Barbosa, Jr. | last post by:
All, Any ideas on how to convert the first 8 bytes of raw uninterpreted sequence of bytes from 'char array;' (populated with _binary_ data read from a socket), into a 'long id'? Thank you! ...
3
by: j.a. harriman | last post by:
Hi, On MSDN I know there is a JScript example (Upgrading Visual C++ Projects to Visual Studio .NET in Batch Mode) to upgrade VS6 C++ projects to .NET solutions. It converts the project files...
19
by: silentlights | last post by:
Hi, Can you help me conver a char array into an integer. I am trying something like.. char carray; int numb; carray = 1; carray = 5; carray = 1;
8
by: moondaddy | last post by:
I need to convert a byte array to a string and pass it as a parameter in a URL and then convert it back to the original byte array. However, its getting scrambled in the conversion. In short,...
5
by: byte8bits | last post by:
Here's how I'm doing this right now, It's a bit slow. I've just got the code working. I was wondering if there is a more efficient way of doing this... simple example from interactive Python: ...
2
by: cablepuff | last post by:
template <typename ContainerType> ContainerType rsa_encrypt_list(const std::string&, const typename ContainerType::reference, const typename ContainerType::reference); const BigInteger...
4
by: Jeff | last post by:
Hey ..NET 2.0 In my code am I trying to convert an int value into a decimal: decimal d = 0; int k = 87664; d = Convert.ToDecimal(k/100);
2
by: joe shoemaker | last post by:
I would like to convert url into md5 hash. My question is that md5 hash will create collision at 2^64. If you do long(value,16), where value is the md5 hash string, would value returned from...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.