Re: How to display a number?

From: Cedric Sodhi <manday_at_gmx.net>
Date: Mon, 5 Apr 2010 12:06:12 +0200


I must rephrase my question, it was a little misleading. If not only displaying a number in the console is necessary, which can be handled by   "<<" but I want to display it elsewhere, say in a TText, I need to convert it to a char*.

I thought about using stringstreams but my previous experience shows that CINT is not capable of using stringstreams (I send a mail regarding a related issue a few days ago).

There are severe, random performance drops with using stringstream members such as clear( ). On a plain simple istringstream it takes almost a second to finish - it's impossible for me to determine why.

Then, using a stringstream to just perform such a simple task as displaying a float appears to me like a overhead - given that I'll eventually have to convert it to a CString again.

snprintf is actully just the right candidate for the job, but CINT doesnt appear to know it.

Cedric

James Jackson wrote:

> Surly std::cout << myNumber; will do the trick?
> 
> Or you could use a stringstream, I've used that in CINT before.
> 
> Regards,
> James.
> 
> On 5 Apr 2010, at 11:56, Cedric Sodhi wrote:
> 

>> Simple task, one would assume. C++ offers quite a bunch of facilities to
>> display a number as a string, such as
>>
>> boost::lexical_cast< string >
>> printf
>> sprintf
>> snprintf
>>
>> Unfortunally, CINT doesn't recognize any of them (I didn't even try to
>> use boost because that's kind of out of the question in the first
>> place). I don't understand why among the printf functions from <cstdio>
>> only printf is recognized...
>>
>> Anyway, how do you tackle this apparently impossible task which should
>> actually be pretty common?
>>

> Received on Mon Apr 05 2010 - 12:06:17 CEST

This archive was generated by hypermail 2.2.0 : Mon Apr 05 2010 - 17:50:01 CEST