Hi,
Considering the following code
DataRow myRow = myTable.NewRow();
Decimal myDec = new Decimal( 0, 0, 0, false, 3 ); // 0.000
Console.WriteLine(myDecimal + " " + NumberOfDec(myDec));
myRow["decimal"] = myDec;
Console.WriteLine(myRow["decimal"].ToString() + " " +
NumberOfDec((Decimal)myRow["decimal"]));
Where NumberOfDec is
public static int NumberOfDecimals(System.Decimal decVal)
{
int[] bits = System.Decimal.GetBits(decVal);
int retVal= Convert.ToInt32(System.BitConverter.GetBytes(bits[3])[2]);
return retVal;
}
The output of this code is
0 3
0 0
In other words myDec is 0 (zero) but with 3 decimals. But when adding
it to myRow it loses the information about 3 decimals.
When looking at myDec and myRow["decimal"]) in the QuickWatch myDec's
flag property is 196608 but myRow["decimal"]) flag property is 0.
I can't understand why the value get changed when I am adding it. I
really need the information about how many decimal places the value
contains.
Any suggestions/explanations, is it a bug??
/Carl
|