below 0.0001m numbers, decimal in serialization, is bug fixed?

X

Xavier Wargny

Hi all and each!
Since july, I'm working with dot NET technology. Confident with brand
new tools it gave, I decided to use that new decimal type (related
with the Database type...). After many 'plantages' (critical stops?)
in the communication between my Calculation serveur and my Interface
server, I discovered a problem with the serialization of decimals,
because some values I use are below the Critical Number 0.0001m (I
should blame myself for that, but sometimes, I have to compute with
pressures around Pa, so 1/100000 bars...)
Some functions where I couldn't deal other way, I put strings or
floats instead of having decimals, but I really hate coding like that,
because both side, it comes from or go to decimals.
And today, I saw an old message written in january :

//------------------------------------------------------------------
//Message n° 6 de ce fil
//De :Bobby Mattappally [MSFT] ([email protected])
//Objet :RE: MS Bug? ... Deserialization and Decimal with Exponents
//Groupes de discussion :microsoft.public.dotnet.languages.csharp
//Date :2003-01-16 23:36:04 PST
//
//>Being from MS, can you confirm that this is in fact a bug
//>and if it has been fixed in some to be released version
//>of .net? And if there is a work around for this.
//
//I am told the default behavior for the Decimal.Parse function of not
//accepting Exponents is by design.
//Since decimals represent exact values, it doesn't make sense to
represent
//them in E form. You might as well use Double.
//
//Are you explicitly using the Exponent form in your code? If not, you
may be
//hitting a bug.
//There is a bug , whereby Decimal values less than .0001 gets
serialized
//into Exp format and when deserializing it you get exception. This is
fixed
//in the next version.
//------------------------------------------------------------------

As bobby says, the problem should be fixed in the previous version.
At work, I was said that we use SP2, which is, I think, the last
version. As we are now in december this version must be the "next",
that they were talking about? I'm asking the question because it
doesn't seem having changed anything... And in the fixed problem list
corresponding to the SP2, I didn't see anything related with decimals!
If someone, could please tell me?
 
N

Nick Malik

I'm not aware of the bug. I don't see it referenced in MSDN.

What version of the Microsoft .NET Framework are you using?

--- Nick
 
X

Xavier Wargny

Nick Malik said:
I'm not aware of the bug. I don't see it referenced in MSDN.

What version of the Microsoft .NET Framework are you using?


Well, my version is 1.0.3705
I imagine you can just understand the problem with the following
example :
decimal d = 0.000001m ;
string s = d.ToString() ;
d = decimal.Parse(s) ;
this compile, but cannot operate :
Exception Details: System.FormatException: Input string was not in a
correct format.

The rest of the explanation is not interresting, the fact is that
decimal.ToString() method for a decimal under 0.0001m, gives such a
string :
xE-n (where x is a decimal and n an integer)
You can force the string by adding a format as a ToString's parameter
(d.ToString("#0.0######"))
My thought is that serialization use that "stupid" ToString() without
giving the choice on which format to be serialized...
Is there a bug? Is it fixed in a known version?
Is there another way to process decimals serialization?
 
W

Willy Denoyette [MVP]

Works as expected in version 1.1.

Willy.

Xavier Wargny said:
"Nick Malik" <[email protected]> wrote in message


Well, my version is 1.0.3705
I imagine you can just understand the problem with the following
example :
decimal d = 0.000001m ;
string s = d.ToString() ;
d = decimal.Parse(s) ;
this compile, but cannot operate :
Exception Details: System.FormatException: Input string was not in a
correct format.

The rest of the explanation is not interresting, the fact is that
decimal.ToString() method for a decimal under 0.0001m, gives such a
string :
xE-n (where x is a decimal and n an integer)
You can force the string by adding a format as a ToString's parameter
(d.ToString("#0.0######"))
My thought is that serialization use that "stupid" ToString() without
giving the choice on which format to be serialized...
Is there a bug? Is it fixed in a known version?
Is there another way to process decimals serialization?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top