This content has been marked as final. Show 5 replies
Thank you for the Info. We are already doing this as a workaround until we find a proper solution.
Our application is a financial application and it is all about numbers (Currency, interest....) which are all Double variable and we are using Dataset throughout our application.
We will load different columns or tables based on different conditions and calculations. So it will be very difficult to know which column will be what.
I was just hoping there is permanent fix, as this is clearly a ODP.net issue.
I am even more surprised that no one has seen this problem
Thank you for time Dennis, I appreciate it.
Edited by: 936235 on May 29, 2012 8:56 AM
Under solution has a bug.
from this site
oracle datatype : Number(p,s) : 0 < s < p < 16 ==> Double
so, modify table datatype to another(p >= 16)
This is has a bug.
1. dataadapter fillschema
2. double column datatype convert decimal
3. dataAdapter fill
' 먼저 Schema 만 읽어서
' Column Type Double 인것을 Decimal 로 변경 ============================
For Each dc As DataColumn In dtschema.Columns
If _dc.DataType.Equals(GetType(Double)) Then
_dc.DataType = GetType(Decimal)
Have a nice day^^
Edited by: nami on 2013. 4. 1 오전 12:17
At the heart of it, the problem is conversions between decimal and double, as they're not the same thing. Double (and all floating point math) have certain numbers that they can't precisely represent. (See this for the gory details: http://stackoverflow.com/questions/1089018/why-cant-decimal-numbers-be-represented-exactly-in-binary )
If you need the exact value, you want to use decimal as the type. I don't use DataAdapter.Fill(), so I'm not sure how you tell it to do that. (I tend to populate objects myself by reading from the reader and using the various get methods, in which case I can just tell it I want a decimal.)
edit - Oh yeah, I just saw the part about you doing financial stuff. Definitely use decimal then. Financial math is the main reason it was created.
Edited by: Tridus on Apr 2, 2013 11:05 AM
Just as a further comment on this, if you're really using double everywhere in your application you probably already have this problem without realizing it. Try this:
The problem there is that 0.1 is one of the numbers that double can't represent, so you get something close to it but not quite right.
double i = 0.1 + 0.1 + 0.1; // 0.30000000000000004 decimal j = 0.1m + 0.1m + 0.1m; // 0.3
I'm kind of surprised it even gave you doubles by default if the Oracle columns have a fairly small precision. I know EF will give you a decimal by default for something like NUMBER(11,5), AFAIK the provider specific value is an OracleDecimal, if that setting is on, and according to the documentation it's also supposed to give you a decimal.