## double to wxLongLong conversion (newbie question) Topic is solved

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Michal
In need of some credit
Posts: 5
Joined: Thu Nov 15, 2007 5:15 pm

### double to wxLongLong conversion (newbie question)

Hi;
I want to present small double number (lets say 0.0078) in wxGrid cell. But when i type this:

wxLongLong helper;
helper.Assign(0.0078);
SetCellValue(4, 3, helper.ToString());

than cell contain only zero. How to convert double to wxLongLong and avoid truncation? Is it a problem whit cell format?

doublemax
Moderator
Posts: 14952
Joined: Fri Apr 21, 2006 8:03 pm
Location: \$FCE2
wxLongLong is an integer type, it can't hold floating point values. Why don't you just use a double?
Use the source, Luke!

Michal
In need of some credit
Posts: 5
Joined: Thu Nov 15, 2007 5:15 pm
>Why don't you just use a double?

Because you can pass only wxString as third argument of SetCellValue and I can convert double to wxString (or I don't know how)... I don't know any wx class similar to double.

doublemax
Moderator
Posts: 14952
Joined: Fri Apr 21, 2006 8:03 pm
Location: \$FCE2

Code: Select all

``````double v=0.0078f;
wxString s;
s << v;
SetCellValue(4, 3, s);

alternatively:
SetCellValue(4, 3, wxString::Format(wxT("%f"), v)); ``````
Last edited by doublemax on Fri Jan 04, 2008 6:22 pm, edited 1 time in total.
Use the source, Luke!

timg
Earned some good credits
Posts: 148
Joined: Mon Jan 23, 2006 6:52 pm
you can just do it like this:

Code: Select all

``````mygrid->SetCellValue(4, 3, wxString::Format("%f", mydouble));
``````