https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112020-08-11T14:38:41ZRuby Issue Tracking SystemRuby master - Bug #17114: Float is not properly kept as integer when integer is added without spacehttps://redmine.ruby-lang.org/issues/17114?journal_id=870162020-08-11T14:38:41Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Rejected</i></li></ul><p>This is expected. <code>1.0.floor + 1</code> is parsed as <code>((1.0).floor).+(1)</code>. <code>1.0.floor +1</code> is parsed as <code>(1.0).floor(+1)</code>. This is also true for <code>-1</code>, it's just that <code>((1.0).floor).-(1)</code> and <code>(1.0).floor(-1)</code> are both <code>0</code>, since <code>(floor).floor(-1)</code> means the floor of the 10s column. You'll get different results for <code>10.0.floor -1</code> and <code>10.0.floor - 1</code>.</p> Ruby master - Bug #17114: Float is not properly kept as integer when integer is added without spacehttps://redmine.ruby-lang.org/issues/17114?journal_id=870172020-08-11T14:40:46Zahorek (Pavel Rosický)
<ul></ul><p>Hi, it's not a bug. +-1 is a precision argument.</p>
<pre><code>irb> 12.34.floor(-1)
=> 10
irb> 12.34.floor(+1)
=> 12.3
</code></pre>
<p>take a look at the documentation, it describes this exact behavior well.<br>
<a href="https://ruby-doc.org/core-2.7.1/Float.html#method-i-floor" class="external">https://ruby-doc.org/core-2.7.1/Float.html#method-i-floor</a></p>
<p>Returns a floating point number when ndigits is positive, otherwise returns an integer.</p> Ruby master - Bug #17114: Float is not properly kept as integer when integer is added without spacehttps://redmine.ruby-lang.org/issues/17114?journal_id=870182020-08-11T15:14:45Ztammo (tammo tjarks)tammo@tammo-tjarks.de
<ul></ul><p>Hello,<br>
my fault. Thank you for clarification.</p>
<p>Best regards,<br>
Tammo</p> Ruby master - Bug #17114: Float is not properly kept as integer when integer is added without spacehttps://redmine.ruby-lang.org/issues/17114?journal_id=870232020-08-12T00:23:29Zsawa (Tsuyoshi Sawada)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/87023/diff?detail_id=57722">diff</a>)</li></ul>