Ruby Issue Tracking System: Issues
https://bugs.ruby-lang.org/
https://bugs.ruby-lang.org/favicon.ico?1711330511
2018-11-16T17:43:13Z
Ruby Issue Tracking System
Redmine
Ruby master - Bug #15312 (Rejected): Ruby gives me wrong result for plus operation
https://bugs.ruby-lang.org/issues/15312
2018-11-16T17:43:13Z
kot-begemot (Max Zet)
<p>Run into this weird issue today. Tried that on rubies 2.5.1p57 and ruby 2.5.3p105 (i believe this is latest stable at the moment).</p>
<p>Here is how to reproduce it</p>
<pre><code>$ irb
2.5.3 :001 > 2.6 + 0.1
=> 2.7
2.5.3 :002 > 2.7 + 0.1
=> 2.8000000000000003
2.5.3 :003 > 2.8 + 0.1
=> 2.9
</code></pre>
<p>Here some more cases</p>
<pre><code>$ irb
2.5.3 :001 > 2.7 + 0.01
=> 2.71
2.5.3 :002 > 2.79 + 0.01
=> 2.8
2.5.3 :003 > 2.8 - 0.1
=> 2.6999999999999997
2.5.3 :004 > 2.79 + 0.01
=> 2.8
2.5.3 :005 > 2.81 - 0.01
=> 2.8000000000000003
</code></pre>
<p>Haven't discovered other cases yet, if will catch them, will post them here</p>