<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:45:14 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[CSHARP-3416] Discrepanices between BsonDocument and json strings on double values</title>
                <link>https://jira.mongodb.org/browse/CSHARP-3416</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;var document = new BsonDocument { &lt;/p&gt;
{ &quot;double1&quot;, 0.5710711036366942 }
&lt;p&gt; ,&lt;br/&gt;
 { &quot;double2&quot;, 1.1897551732621 } ,&lt;br/&gt;
 { &quot;double3&quot;, 1.680586318655911 } };&lt;/p&gt;

&lt;p&gt;var jsonDoc = document.ToJson();&lt;br/&gt;
 Console.WriteLine(jsonDoc);&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;This default extension methods ToJson will output:&lt;/p&gt;

&lt;p&gt;{ &quot;double1&quot; : 0.5710711036366942&lt;font color=&quot;#FF0000&quot;&gt;2&lt;/font&gt;, &quot;double2&quot; : 1.189755173262&lt;font color=&quot;#FF0000&quot;&gt;0999&lt;/font&gt;, &quot;double3&quot; : 1.68058631865591&lt;font color=&quot;#FF0000&quot;&gt;09&lt;/font&gt; }&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;while insert this bson document into MongoDB won&apos;t introduce the discrepancy, the ToJson method will change the valid double values.&#160;&#160;&lt;/p&gt;

&lt;p&gt;1. Could this be resolved by customized&#160;IBsonSerializer or&#160;JsonWriterSettings?&lt;/p&gt;

&lt;p&gt;2. Is it more reasonable to keep the same value in default ToJson() ?&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;Thanks for the time and efforts in advance.&lt;/p&gt;</description>
                <environment>.net framework 4.7.2</environment>
        <key id="1617407">CSHARP-3416</key>
            <summary>Discrepanices between BsonDocument and json strings on double values</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="13202">Works as Designed</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="jiaxson@microsoft.com">Jiaxing Song</reporter>
                        <labels>
                    </labels>
                <created>Tue, 9 Feb 2021 06:52:46 +0000</created>
                <updated>Fri, 27 Oct 2023 13:24:46 +0000</updated>
                            <resolved>Wed, 10 Feb 2021 00:32:46 +0000</resolved>
                                    <version>2.10.4</version>
                                                    <component>BSON</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="3641641" author="mikalai.mazurenka" created="Tue, 2 Mar 2021 12:28:21 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jiaxson%40microsoft.com&quot; class=&quot;user-hover&quot; rel=&quot;jiaxson@microsoft.com&quot;&gt;jiaxson@microsoft.com&lt;/a&gt;, it&apos;s not about MongoDB specific types but about C# literal types. Please see: &lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/floating-point-numeric-types#real-literals&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Real literals&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3626855" author="JIRAUSER1258644" created="Mon, 22 Feb 2021 02:47:55 +0000"  >&lt;p&gt;Hello @Mikalai Mazurenka&lt;/p&gt;

&lt;p&gt;Thanks for your suggestions. Here my source data was json string, I didn&apos;t explicitly assign the type(double or decimal)&lt;/p&gt;

&lt;p&gt;So does BsonDocument detect floating number as double by default? How do I change the default type to decmical?&lt;/p&gt;

&lt;p&gt;Another confusion is&#160; numbers like 1.1897551732621 should be double precesion but still have this discrepancy&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</comment>
                            <comment id="3608274" author="mikalai.mazurenka" created="Wed, 10 Feb 2021 00:21:13 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jiaxson%40microsoft.com&quot; class=&quot;user-hover&quot; rel=&quot;jiaxson@microsoft.com&quot;&gt;jiaxson@microsoft.com&lt;/a&gt;,&lt;br/&gt;
Thank you for reporting this issue.&lt;br/&gt;
Essentially it boils down to representation of floating-point numbers (&lt;a href=&quot;https://floating-point-gui.de/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://floating-point-gui.de/&lt;/a&gt;).&lt;br/&gt;
The discrepancy is not introduced when writing/reading the data in database because there&apos;s no conversion along the way.&lt;br/&gt;
You cannot change this behavior with custom&#160;&lt;tt&gt;IBsonSerializer&lt;/tt&gt;&#160;or&#160;&lt;tt&gt;JsonWriterSettings&lt;/tt&gt;&lt;br/&gt;
You can use decimal instead of double if you need to guarantee the round trip representation.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                    <customfield id="customfield_13552" key="com.go2group.jira.plugin.crm:crm_generic_field">
                        <customfieldname>Case</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[[5002K00000scQ5eQAE]]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hyfn67:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>