PC Review


Reply
Thread Tools Rate Thread

When adding a System.Decimal Zero (0.000) to a DataRow the bit information get lost

 
 
Carl G
Guest
Posts: n/a
 
      13th Jul 2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lost System Information Roger Windows XP Help 13 11th Jun 2010 08:58 PM
System Volume Information Lost BR Dave Windows XP Help 2 25th Aug 2008 12:44 PM
Problem: DataRow alters stored System.Decimal values. Carl G Microsoft Dot NET 2 15th Jul 2004 03:33 PM
Adding datarow to datarow and datragrid DotNetJunkies User Microsoft VB .NET 1 15th Jul 2004 12:42 AM
Lost my System Information Walter E. Windows XP General 1 16th Oct 2003 08:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:52 AM.