Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8357255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:25:20+00:00 2026-06-09T10:25:20+00:00

In our Oracle database, I have a table (say MYTABLE) with column VALUE_NUMBER of

  • 0

In our Oracle database, I have a table (say MYTABLE) with column VALUE_NUMBER of type NUMBER (NULL, no precision specified). This table contains a value 1178.2

When retrieving data from this column using standard ADO.Net (actually ODP.Net) and then converting the decimal value to a string, I get ‘1178.20’. Obviously, when converting the constant 1178.2M to a string, the output is 1178.2.

Digging deeper, I looked at the output of decimal.GetBits(), which turned out to be different, although when comparing both numbers they are really considered equal.

The code sample below illustrates the behaviour:

using (var connection = new OracleConnection("my connection string"))
{
    connection.Open();
    var command = connection.CreateCommand();
    command.CommandText = "SELECT VALUE_NUMBER FROM MYTABLE";
    command.CommandType = CommandType.Text;
    using (command)
    {
        var reader = command.ExecuteReader(CommandBehavior.Default);
        reader.Read();
        decimal oracleDecimal = reader.GetDecimal(reader.GetOrdinal("VALUE_NUMBER"));
        Console.WriteLine(oracleDecimal); // output: 1178.20 (NOT expected)
        var bitsFromOracle = decimal.GetBits(oracleDecimal).Select(x => x.ToString());
        var bitsFromOracleString = string.Join(",", bitsFromOracle.ToArray());
        Console.WriteLine(bitsFromOracleString); // 117820,0,0,131072

        // sanity check
        const decimal constantDecimal = 1178.2M;
        Console.WriteLine(constantDecimal); // output: 1178.2 (expected)
        var bitsFromConstant = decimal.GetBits(constantDecimal).Select(x => x.ToString());
        var bitsFromConstantString = string.Join(",", bitsFromConstant.ToArray());
        Console.WriteLine(bitsFromConstantString); // 11782,0,0,65536

        Console.WriteLine(oracleDecimal == constantDecimal); // True 
    }
}

How should this be explained?

Here’s the table CREATE & INSERT script to make this work:

CREATE TABLE MYTABLE (
  ID  NUMBER(10)             NOT NULL,
  VALUE_NUMBER           NUMBER
);

INSERT INTO MYTABLE(ID,VALUE_NUMBER) VALUES(1,1178.2);

UPDATE:

The answer by @Vash and his subsequent comment led to the right conclusion that the .Net decimal type actually contains information about it’s number of digits, even if they are irrelevant for equality. 1178.2M and 1178.20M have a different bit representation because of this, although obviously the .Equals() method and == operator consider these numbers equal.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T10:25:21+00:00Added an answer on June 9, 2026 at 10:25 am

    The main problem you have is that you do not apply any format to row data that you recieve from data base.

    If you want to have specific format you should specyfy it. In documentation you will find Formatting Types, there are all information how to deal with formatting.

    If you just want to have result

    Console.WriteLine(valueNumber.ToString("N1", CultureInfo.InvariantCulture));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In our Oracle database we have a table called RULES, with a field called
I have an Oracle (10.2.0.4) database table with a column which is encrypted by
I have a data mart mastered from our OLTP Oracle database using basic Materialized
I have a table in an Oracle database that contains actions performed by users
We have a shell script that perform a physical backup of our oracle database
I am using Oracle 10g Enterprise edition. A table in our Oracle database stores
I have a table that exists in an Oracle database, but doesn't show on
I need to find all the tables in our Oracle database that have attributes
We ran into serious performance problems with our Oracle database and we would like
I am trying to retrieve CLOB data from our Oracle database. the code is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.