Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Convert double to AnsiString

291 views
Skip to first unread message

Cristiano de Araujo Resende

unread,
Sep 27, 2004, 11:00:40 AM9/27/04
to

How can I convert a double to AnsiString?

Andrue Cope [TeamB]

unread,
Sep 27, 2004, 11:14:37 AM9/27/04
to
Cristiano de Araujo Resende wrote:

> How can I convert a double to AnsiString?

You can't.

However I assume that what you /really/ want to do is make an
AnsiString contain the textual representation of a double value.
AnsiString has many constructors and one of them takes a double so:

double wibble;
AnsiString wibbleAsAString( wibble );

or

double wibble;
AnsiString wibbleAsAString=wibble;

Note that the reverse operation is provided by the ToDouble() method.
--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html

Chris Uzdavinis

unread,
Sep 27, 2004, 11:29:56 AM9/27/04
to
"Cristiano de Araujo Resende" <cris...@alol.com.br> writes:

> How can I convert a double to AnsiString?

AnsiString has a constructor taking a double. The copy assignment
operator takes an AnsiString.

Thus, you can directly construct it like this:

double dblval = ...;
AnsiString(dblval);

Or you can implicitly convert it:

double dblval = ...;
AnsiString str;
str = dblval;

The 2nd case creates a temporary AnsiString (implicitly) and assigns
that to str.

--
Chris (TeamB);

Vladimir Stefanovic

unread,
Sep 27, 2004, 12:49:12 PM9/27/04
to
What's wrong with FloatToStr() function?


--


Best regards,
Vladimir Stefanovic

Cristiano de Araujo Resende <cris...@alol.com.br> wrote in message
news:41582b18$1...@newsgroups.borland.com...

0 new messages