Bug #1892
closedTableView render double incorrect
0%
Description
I have a WTableView that has some collumns with the value 50.54 from a QueryModel,
but the table shows me 50.53999999999
Updated by Stefan Ruppert over 11 years ago
Ariel Kruger wrote:
I have a WTableView that has some collumns with the value 50.54 from a QueryModel,
but the table shows me 50.53999999999
Hi,
I had a similar problem. AFAIK Wt uses sprintf("g") to format a double value in its string stream which can lead in such output. Also boost::lexical_caststd::string(double) is used. I uses an explicit sprintf(".2f") which solved my formatting issue.
However maybe double to string conversion should be unified and made more flexible by providing a setter for specifying the used formatter string for sprintf()!?
Regards,
Stefan
Updated by Koen Deforche over 11 years ago
- Status changed from New to Closed
- Assignee set to Koen Deforche
- Target version set to 3.3.0
Hey,
What you should do is configure the TextFormat in the item delegate that is used to render the double data.
Another solution is to provide DisplayRole data as strings, but keep the double as EditRole data; this is really the spirit of the different roles for the models. You can do that by specializing QueryModel (in this case).
Regards,
koen