Strange "rounding" issue

Strange "rounding" issue

Postby chrsadk » Fri 09 Sep 2011 10:44

Hello,

I am using dotConnect for Oracle 5.0.1.0.

I'm having an issue with certain double values, when saving them to the database. For instance, when saving the double 33.36 (through a normal parameterized Oracle command), the value in Oracle after comitting is 33.359999999999992.

I know there is an accuracy aspect to doubles, but it seems odd this happens on the second digit after the separator.

The issue happens on (for instance) 29.36, 30.36, ..., 57.36.

Updating Oracle with these values through a prompt (not using dotconnect) does not have the issue.

Any idea what is causing this?

EDIT: The oracle column data type is an unconstrained NUMBER.

Best regards,
Christian Andersen
chrsadk
 
Posts: 3
Joined: Fri 09 Sep 2011 10:22

Postby Shalex » Mon 12 Sep 2011 16:36

I have tried the following code with dotConnect for Oracle v 6.50.214:
Code: Select all
DDL:
CREATE TABLE ALEXSH.NUMBERTABLE (
  NUMBERCOLUMN NUMBER(38, 10));

C#:
    using (OracleConnection conn = new OracleConnection()) {
        conn.ConnectionString = "Direct=true;sid=orcl1120;server=***;uid=***;pwd=***;";
        //conn.ConnectionString = "server=orcl1120;uid=***;pwd=***;";
        conn.Open();
        OracleCommand cmd = conn.CreateCommand();
        cmd.CommandText = "insert into numbertable values (:p1)";
        cmd.Parameters.Add("p1", OracleDbType.Number).Value = 33.36;
        cmd.ExecuteNonQuery();
    }

The values in Oracle in both cases (the Direct and OCI modes) are 33.36.
Please try the latest (6.50.214) version of dotConnect for Oracle. If the problem persists, send us a small test project with the corresponding DDL script.
Shalex
Devart Team
 
Posts: 7539
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for Oracle