This is a serious bug in .NET 1.1
Using SQL select one field from Oracle table,
This column Oracle data type is: Number(18),
the field value is: 235312035283022003
which is the correct value.
However, using DataReader,
(We want the end result is long type, the only way is GetDouble(reader,0))
Here is the horrible result .NET Returns:
long viewId = 0;//We want the end result is long type,
double dViewId = reader.GetDouble(0);
viewId = (long)dViewId; // we get 235312035283022016
string sViewId = dViewId.ToString("R");//we get "2.35312035283022E+17"
sViewId = dViewId.ToString("F0");//we get 235312035283022000
viewId = long.Parse(sViewId);//235312035283022000
No matter what, we cannot get the correct value:
235312035283022003
This bug happenend when double value reaching 18 digit long.
It is fine when under 17 digit.
Any known work around?
How Microsoft proved .NET is able to be mission-critical?
We are a leading Telecom company, currently reaching the buggy-threshold in
our billing system due to this bug. Any help are appreciated.
Thanks.
Jordan
Göran Andersson - 30 Jun 2006 06:16 GMT
Why are you sending the value as a double? That means that the
information is lost before it even reaches the .NET code.
Not even .NET can recreate information out of thin air...
> This is a serious bug in .NET 1.1
>
[quoted text clipped - 29 lines]
> Thanks.
> Jordan
Nick Malik [Microsoft] - 30 Jun 2006 09:14 GMT
Use the Decimal Datatype, not double.
Double is a floating point number. Decimal is a fixed radix number and will
have no problem with your 18 digit long value. The limit for decimal is 28
significant digits.
http://msdn2.microsoft.com/en-us/library/364x0z75.aspx

Signature
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
> This is a serious bug in .NET 1.1
>
[quoted text clipped - 30 lines]
> Thanks.
> Jordan
Jon Skeet [C# MVP] - 02 Jul 2006 14:49 GMT
> Use the Decimal Datatype, not double.
That much I agree with.
> Double is a floating point number. Decimal is a fixed radix number and will
> have no problem with your 18 digit long value.
Well, Decimal is a floating point type as well. Both double and decimal
have a fixed radix - for double it's 2, and for decimal it's 10.
See
http://www.pobox.com/~skeet/csharp/floatingpoint.html
http://www.pobox.com/~skeet/csharp/decimal.html

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too