<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="fn main() {
    // Both asserts give:
    // 'assertion failed: `(left == right)` (left: `-2`, right: `-3`)'
    assert_eq!( -2.4_f32.floor(), (-2.4_f32).floor() );
    assert_eq!( -2.4_f64.floor(), (-2.4_f64).floor() );
}"><pre class="notranslate"><code class="notranslate">fn main() {
    // Both asserts give:
    // 'assertion failed: `(left == right)` (left: `-2`, right: `-3`)'
    assert_eq!( -2.4_f32.floor(), (-2.4_f32).floor() );
    assert_eq!( -2.4_f64.floor(), (-2.4_f64).floor() );
}
</code></pre></div>
<p dir="auto">rustc 1.2.0 (<a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/rust-lang/rust/commit/082e4763615bdbe7b4dd3dfd6fc2210b7773edf5/hovercard" href="https://github.com/rust-lang/rust/commit/082e4763615bdbe7b4dd3dfd6fc2210b7773edf5"><tt>082e476</tt></a> 2015-08-03)<br>
binary: rustc<br>
commit-hash: <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/rust-lang/rust/commit/082e4763615bdbe7b4dd3dfd6fc2210b7773edf5/hovercard" href="https://github.com/rust-lang/rust/commit/082e4763615bdbe7b4dd3dfd6fc2210b7773edf5"><tt>082e476</tt></a><br>
commit-date: 2015-08-03<br>
host: x86_64-unknown-linux-gnu<br>
release: 1.2.0</p>
<p dir="auto">Right now, methods on negative literals take precedence over the unary operator:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="1.32.abs(): 1
-1.32.abs(): -1
pos.abs(): 1
neg.abs(): 1
-pos.abs(): -1
-neg.abs(): -1"><pre class="notranslate"><code class="notranslate">1.32.abs(): 1
-1.32.abs(): -1
pos.abs(): 1
neg.abs(): 1
-pos.abs(): -1
-neg.abs(): -1
</code></pre></div>
<p dir="auto">Playpen: <a href="http://is.gd/0YgB1E" rel="nofollow">http://is.gd/0YgB1E</a></p>
<p dir="auto">While that <a href="http://mathforum.org/library/drmath/view/53194.html" rel="nofollow">might make sense</a> from a mathematical point of view, I think it's rather unintuitive.</p>
<p dir="auto">I see two ways to improve this issue:</p>
<ul dir="auto">
<li>According to someone in the #rust channel, "ruby treats -3.abs as (-3).abs and -x.abs as -(x.abs)". I find that quite intuitive.</li>
<li>The compiler could generate a warning if a method is called on a negative literal without using parentheses to make things more explicit. Otherwise this might cause subtle bugs.</li>
</ul>
<p dir="auto">Is a change related to precedence even possible now that 1.0 is stable?</p>