By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,723 Members | 842 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,723 IT Pros & Developers. It's quick & easy.

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

P: n/a
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] (bo****@online.microsoft.com)
//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?
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

"Xavier Wargny" <xa****@yahoo.fr> wrote in message
news:48**************************@posting.google.c om...
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] (bo****@online.microsoft.com)
//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?

Nov 15 '05 #2

P: n/a
"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message news:<AVRFb.622785$HS4.4563831@attbi_s01>...
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?
Nov 15 '05 #3

P: n/a
Works as expected in version 1.1.

Willy.

"Xavier Wargny" <xa****@yahoo.fr> wrote in message
news:48**************************@posting.google.c om...
"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message

news:<AVRFb.622785$HS4.4563831@attbi_s01>...
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?

Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.