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 changes when I am adding it. I really need to the information about how many decimal the value contains.
Any suggestions/explanations ??
/Carl
---
Posted using Wimdows.net NntpNews Component -
Post Made from
http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.