<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:39:40 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>[SERVER-16007] Inconsistent rounding in float parser</title>
                <link>https://jira.mongodb.org/browse/SERVER-16007</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;I assume the server is handling EcmaScript parsing... &lt;/p&gt;

&lt;p&gt;This is capricious and I am not sure if it is happening in parseFloat or in toFixed()&lt;/p&gt;

&lt;p&gt;Some values are not being properly rounded. And sometimes the same value will be rounded differently on subsequent attemtps (see &apos;steps to reproduce&apos;).&lt;/p&gt;

&lt;p&gt;It appears that repeating the rounding calculation produced an accurate result: first time does not.&lt;/p&gt;
</description>
                <environment></environment>
        <key id="167820">SERVER-16007</key>
            <summary>Inconsistent rounding in float parser</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="9">Done</resolution>
                                        <assignee username="ramon.fernandez@mongodb.com">Ramon Fernandez Marina</assignee>
                                    <reporter username="ccjon">Jon Gorrono</reporter>
                        <labels>
                    </labels>
                <created>Fri, 7 Nov 2014 01:38:43 +0000</created>
                <updated>Thu, 4 Dec 2014 21:40:03 +0000</updated>
                            <resolved>Thu, 4 Dec 2014 19:03:36 +0000</resolved>
                                                                    <component>JavaScript</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="778973" author="ccjon" created="Thu, 4 Dec 2014 21:40:03 +0000"  >&lt;p&gt;Thanks, Ramon..... I&apos;ll do that.&lt;/p&gt;</comment>
                            <comment id="777659" author="ramon.fernandez" created="Wed, 3 Dec 2014 19:22:03 +0000"  >&lt;p&gt;Apologies for the late reply &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=ccjon&quot; class=&quot;user-hover&quot; rel=&quot;ccjon&quot;&gt;ccjon&lt;/a&gt;. Both &lt;tt&gt;toFixed()&lt;/tt&gt; and &lt;tt&gt;parseInt()&lt;/tt&gt; are implemented by the V8 shell, which is what the mongo shell is using. I took two cases from your repro and run them in Chrome&apos;s V8 shell, and I was able to reproduce this behavior:&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&amp;gt; var i = 1.2345&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&amp;gt; i.toFixed(3)&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&quot;1.234&quot;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&amp;gt; var j = 1.234525&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&amp;gt; j.toFixed(3)&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&quot;1.235&quot;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;
&lt;p&gt;I took a look at &lt;a href=&quot;http://www.ecma-international.org/ecma-262/5.1/#sec-15.7.4.5&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;the spec for the &lt;tt&gt;toFixed()&lt;/tt&gt; function&lt;/a&gt;, and there could be a bug; in step 8.a it reads:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Let n be an integer for which the exact mathematical value of n &#247; 10^f &#8211; x is as close to zero as possible. If there are two such n, pick the larger n.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Now &lt;tt&gt;x&lt;/tt&gt; refers to our &lt;tt&gt;i&lt;/tt&gt;, so for the case where &lt;tt&gt;x = 1.2345&lt;/tt&gt; this means:&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;1234/1000 - 1.2345 = -0.0005&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;1235/1000 - 1.2345 = +0.0005&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;
&lt;p&gt;The way I read the spec I understand that &quot;n&quot; should be 1235, but seems like 1234 is being picked instead. Perhaps the comparison is not on &quot;n&quot; but on &quot;abs&amp;#40;n)&quot;, and when there are two identical &quot;n&quot; one of them is chosen arbitrarily?&lt;/p&gt;

&lt;p&gt;Unless I&apos;m missing something the issue appears to be within V8 itself, so I&apos;d suggest you open a ticket in the &lt;a href=&quot;https://code.google.com/p/v8/issues/list&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;V8 issue tracker&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Cheers,&lt;br/&gt;
Ram&#243;n.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 3 Dec 2014 19:22:03 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        9 years, 10 weeks, 6 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></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_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>ian@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            9 years, 10 weeks, 6 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10026"><![CDATA[ALL]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>ccjon</customfieldvalue>
            <customfieldvalue>ramon.fernandez@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrljpb:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hs3qsf:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>146719</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10750" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Steps To Reproduce</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p&gt;&amp;gt; var i = 1.2345&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(1))&lt;br/&gt;
1.2&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(2))&lt;br/&gt;
1.23&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(3))&lt;br/&gt;
1.234  &amp;lt;- should be a &apos;5&apos;&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(4))&lt;br/&gt;
1.2345&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(3))&lt;br/&gt;
1.234 &amp;lt;- should be a &apos;5&apos;&lt;br/&gt;
&amp;gt; var i = 1.234525&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(5))&lt;br/&gt;
1.23453 &amp;lt;- correct&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(4))&lt;br/&gt;
1.2345&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(3))&lt;br/&gt;
1.235 &amp;lt;- correct (mark as &apos;wtf&apos;)&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(1))&lt;br/&gt;
1.2&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(2))&lt;br/&gt;
1.23&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(3))&lt;br/&gt;
1.235 &amp;lt;- correct &lt;br/&gt;
&amp;gt; var i = 1.234525 (same variable, same value)&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(1))&lt;br/&gt;
1.2&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(2))&lt;br/&gt;
1.23&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(3))&lt;br/&gt;
1.235 &amp;lt;- correct&lt;br/&gt;
&amp;gt; var i = 1.22334455 (same variable, &lt;b&gt;new&lt;/b&gt; value)&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(1))&lt;br/&gt;
1.2&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(2))&lt;br/&gt;
1.22&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(3))&lt;br/&gt;
1.223&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(4))&lt;br/&gt;
1.2233&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(5))&lt;br/&gt;
1.22334&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(6))&lt;br/&gt;
1.223345 &amp;lt;- correct&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(7))&lt;br/&gt;
1.2233445&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(1))&lt;br/&gt;
1.2&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(2))&lt;br/&gt;
1.22&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(3))&lt;br/&gt;
1.223&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(4))&lt;br/&gt;
1.2233&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(5))&lt;br/&gt;
1.22334&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(6))&lt;br/&gt;
1.223345 &amp;lt; -correct&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(7))&lt;br/&gt;
1.2233445&lt;br/&gt;
&amp;gt; parseFloat(i.toFixed(6))&lt;br/&gt;
1.223345 &amp;lt;-correct&lt;br/&gt;
&amp;gt; db.version()&lt;br/&gt;
2.6.5&lt;/p&gt;</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hsghvz:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>