Double padded with extra decimal places

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
markspetit
Posts: 1
Joined: Wed 19 Aug 2015 18:45

Double padded with extra decimal places

Post by markspetit » Wed 19 Aug 2015 19:35

- - Urgent need for a solution - -
I'm using Oracle DBConnect version 8.4.274.6 with entity framework 6 against an Oracle 11g database. I have column in a table defined as number (12,2). If that data in the column a value to the right of the decimal point of 33 (e.g. 200000.33) and the whole number portion is a number >=131,099 and < 262150, then the value in the column's property on the domain object is padded with additional numbers e.g. 131099.33000000002.
If the number has a decimal value other than .33, this padding does not happen. e.g. 131099.34, does not have this issue. I have been able to reproduce this consistently. To reproduce, use a table with a column defined as number (12,2), us an app with the versions listed above. Select a row into a domain object for the table and break point on the column. You will see the padding if the numbers are in the range. Use 111.33 (for example) no problem. Interestingly, a ToString() on the property only returns 2 decimal places. But copying the property with no transformation to another double variable keeps on the decimal points. I have test this with updating the data in the database outside the app with SQL Navigator. Inside the app, etc.
Need a fix as soon as possible (or a viable workaround).

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: Double padded with extra decimal places

Post by Pinturiccio » Thu 20 Aug 2015 14:34

We have answered you via e-mail.

glittle
Posts: 12
Joined: Thu 14 Nov 2019 17:51

Re: Double padded with extra decimal places

Post by glittle » Fri 09 Oct 2020 00:53

I have the same problem today. What was the solution?

I can run a query in Oracle and get 43518.20 but in C# it is 43518.200000000004

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Double padded with extra decimal places

Post by Shalex » Fri 09 Oct 2020 21:04

glittle wrote: Fri 09 Oct 2020 00:53 I have the same problem today. What was the solution?

I can run a query in Oracle and get 43518.20 but in C# it is 43518.200000000004
Your connection mode is OCI (via Oracle Client), isn't it? Direct Mode should work correctly.
The difference in the results between OCI and Direct modes is caused by the data type used for reading data from the server:
* OCI reads double (8 bytes)
* Direct reads number (22 bytes) and converts the number to double at the client side.

As a workaround, either change connection mapping from double to decimal with the "Number Mappings = (Number, 1, 15, System.Decimal);" connection string parameter (for the OCI mode) or switch to the Direct mode.

Post Reply