M
Matthieu Tudury
Hi, i got a weird problem with decimal numbers,
Here is a test sample :
float a, b, c;
double da, db, dc;
da = 313.83;
db = 262.4;
dc = db -da;
a = (float)da;
b = (float)db;
c = b - a;
Console.WriteLine(c.ToString());
Console.WriteLine(dc.ToString());
DataSet ds = new DataSet();
ds.Tables.Add("titi");
ds.Tables[0].Columns.Add("number",typeof(float));
ds.Tables[0].Columns.Add("number2",typeof(double));
DataRow dr = ds.Tables[0].NewRow();
dr[0] = c;
dr[1] = dc;
ds.Tables[0].Rows.Add(dr);
Console.WriteLine(ds.GetXml());
and the result :
-51,42999
-51,43
<NewDataSet>
<titi>
<number>-51.4299927</number>
<number2>-51.430000000000007</number2>
</titi>
</NewDataSet>
If Someone can help me solve this problem...
Thanks
Here is a test sample :
float a, b, c;
double da, db, dc;
da = 313.83;
db = 262.4;
dc = db -da;
a = (float)da;
b = (float)db;
c = b - a;
Console.WriteLine(c.ToString());
Console.WriteLine(dc.ToString());
DataSet ds = new DataSet();
ds.Tables.Add("titi");
ds.Tables[0].Columns.Add("number",typeof(float));
ds.Tables[0].Columns.Add("number2",typeof(double));
DataRow dr = ds.Tables[0].NewRow();
dr[0] = c;
dr[1] = dc;
ds.Tables[0].Rows.Add(dr);
Console.WriteLine(ds.GetXml());
and the result :
-51,42999
-51,43
<NewDataSet>
<titi>
<number>-51.4299927</number>
<number2>-51.430000000000007</number2>
</titi>
</NewDataSet>
If Someone can help me solve this problem...
Thanks