why do you have to store the decimal places when they are 0? Just to display

the in the DataRow? Then why don't you just format the output to show 3

decimal places?

Maybe I don't understand your question but it seems like you are storing

data unnecessarily.

"Carl G" <ge*****@hotmail.com> wrote in message

news:86**************************@posting.google.c om...

I am storing a 0.000 a System.Decimal in a DataRow.

On retrieval the value is only 0 without the three decimal places.

It looks like the Get property returns System.Decimal.Zero, but

why????

I can't figure out why the design is so that the DataRow "alters" the

value entered.

In my application a decimal column in a row of a specific table has a

fix number of decimal places according to certain premises. The

premises are quite tedious to calculate so it would be VERY nice if I

could figure out the number of decimal places by looking at the value

stored. However since 0 (zero) can't be stored with a fix amount of

decimal places, I have to store the number of decimal places for each

column in a secondary information source. This secondary information

source gets really huge. For example: one table out of 255 has about

7000 rows with three decimal columns per row.

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 NumberOfDec(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.

Any suggestions/explanations, is it a bug??

/Carl