I am getting a value of a variable from a Gridview (Devexpress XtraGrid). When i multiply the value with 100, it loses its precision. Here is the code i'm using
//Value written on the cell is 0.285
double Width = double.Parse(grdvwDimension.GetRowCellValue(0, "Width");
//Now the value of Width = 0.285
Width = Width * 100;
//Now the value of Width = 28.499999999999996
//It should have been 28.5
I've run into this kind of problem in another project but i found out that i should use either float or double consistently thorough out the project, not both.
I tried some other values, sometimes it works correctly (0.385 becomes 38.5), and sometimes it doesn't (0.274 becomes 27.400000000000002).
I checked what the datatype of the column is, its double. I'm using double consistently in my code.
So, what could be the problem?