pnmixer-rust/num_integer/trait.Integer.html
2017-07-15 01:30:16 +02:00

233 lines
29 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `Integer` trait in crate `num_integer`.">
<meta name="keywords" content="rust, rustlang, rust-lang, Integer">
<title>num_integer::Integer - Rust</title>
<link rel="stylesheet" type="text/css" href="../normalize.css">
<link rel="stylesheet" type="text/css" href="../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../main.css">
<link rel="shortcut icon" href="https://rust-num.github.io/num/favicon.ico">
</head>
<body class="rustdoc trait">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<a href='../num_integer/index.html'><img src='https://rust-num.github.io/num/rust-logo-128x128-blk-v2.png' alt='logo' width='100'></a>
<p class='location'>Trait Integer</p><div class="block items"><ul><li><a href="#required-methods">Required Methods</a></li><li><a href="#provided-methods">Provided Methods</a></li><li><a href="#implementors">Implementors</a></li></ul></div><p class='location'><a href='index.html'>num_integer</a></p><script>window.sidebarCurrent = {name: 'Integer', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content">
<h1 class='fqn'><span class='in-band'>Trait <a href='index.html'>num_integer</a>::<wbr><a class="trait" href=''>Integer</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a class='srclink' href='../src/num_integer/lib.rs.html#23-164' title='goto source code'>[src]</a></span></h1>
<pre class='rust trait'>pub trait Integer: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../num_traits/trait.Num.html" title="trait num_traits::Num">Num</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html" title="trait core::cmp::Ord">Ord</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> {
fn <a href='#tymethod.div_floor' class='fnname'>div_floor</a>(&amp;self, other: &amp;Self) -&gt; Self;
fn <a href='#tymethod.mod_floor' class='fnname'>mod_floor</a>(&amp;self, other: &amp;Self) -&gt; Self;
fn <a href='#tymethod.gcd' class='fnname'>gcd</a>(&amp;self, other: &amp;Self) -&gt; Self;
fn <a href='#tymethod.lcm' class='fnname'>lcm</a>(&amp;self, other: &amp;Self) -&gt; Self;
fn <a href='#tymethod.divides' class='fnname'>divides</a>(&amp;self, other: &amp;Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>;
fn <a href='#tymethod.is_multiple_of' class='fnname'>is_multiple_of</a>(&amp;self, other: &amp;Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>;
fn <a href='#tymethod.is_even' class='fnname'>is_even</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>;
fn <a href='#tymethod.is_odd' class='fnname'>is_odd</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>;
fn <a href='#tymethod.div_rem' class='fnname'>div_rem</a>(&amp;self, other: &amp;Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>Self, Self<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>;
fn <a href='#method.div_mod_floor' class='fnname'>div_mod_floor</a>(&amp;self, other: &amp;Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>Self, Self<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a> { ... }
}</pre>
<h2 id='required-methods'>Required Methods</h2>
<div class='methods'>
<h3 id='tymethod.div_floor' class='method'><span id='div_floor.v' class='invisible'><code>fn <a href='#tymethod.div_floor' class='fnname'>div_floor</a>(&amp;self, other: &amp;Self) -&gt; Self</code></span></h3><div class='docblock'><p>Floored integer division.</p>
<h1 id='examples' class='section-header'><a href='#examples'>Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="macro">assert</span><span class="macro">!</span>(( <span class="number">8</span>).<span class="ident">div_floor</span>(<span class="op">&amp;</span> <span class="number">3</span>) <span class="op">==</span> <span class="number">2</span>);
<span class="macro">assert</span><span class="macro">!</span>(( <span class="number">8</span>).<span class="ident">div_floor</span>(<span class="kw-2">&amp;</span><span class="op">-</span><span class="number">3</span>) <span class="op">==</span> <span class="op">-</span><span class="number">3</span>);
<span class="macro">assert</span><span class="macro">!</span>((<span class="op">-</span><span class="number">8</span>).<span class="ident">div_floor</span>(<span class="op">&amp;</span> <span class="number">3</span>) <span class="op">==</span> <span class="op">-</span><span class="number">3</span>);
<span class="macro">assert</span><span class="macro">!</span>((<span class="op">-</span><span class="number">8</span>).<span class="ident">div_floor</span>(<span class="kw-2">&amp;</span><span class="op">-</span><span class="number">3</span>) <span class="op">==</span> <span class="number">2</span>);
<span class="macro">assert</span><span class="macro">!</span>(( <span class="number">1</span>).<span class="ident">div_floor</span>(<span class="op">&amp;</span> <span class="number">2</span>) <span class="op">==</span> <span class="number">0</span>);
<span class="macro">assert</span><span class="macro">!</span>(( <span class="number">1</span>).<span class="ident">div_floor</span>(<span class="kw-2">&amp;</span><span class="op">-</span><span class="number">2</span>) <span class="op">==</span> <span class="op">-</span><span class="number">1</span>);
<span class="macro">assert</span><span class="macro">!</span>((<span class="op">-</span><span class="number">1</span>).<span class="ident">div_floor</span>(<span class="op">&amp;</span> <span class="number">2</span>) <span class="op">==</span> <span class="op">-</span><span class="number">1</span>);
<span class="macro">assert</span><span class="macro">!</span>((<span class="op">-</span><span class="number">1</span>).<span class="ident">div_floor</span>(<span class="kw-2">&amp;</span><span class="op">-</span><span class="number">2</span>) <span class="op">==</span> <span class="number">0</span>);<a class="test-arrow" target="_blank" href="http://play.integer32.com/?code=extern%20crate%20num_integer%3B%0Afn%20main()%20%7B%0Ause%20num_integer%3A%3AInteger%3B%0Aassert!((%208).div_floor(%26%203)%20%3D%3D%20%202)%3B%0Aassert!((%208).div_floor(%26-3)%20%3D%3D%20-3)%3B%0Aassert!((-8).div_floor(%26%203)%20%3D%3D%20-3)%3B%0Aassert!((-8).div_floor(%26-3)%20%3D%3D%20%202)%3B%0A%0Aassert!((%201).div_floor(%26%202)%20%3D%3D%20%200)%3B%0Aassert!((%201).div_floor(%26-2)%20%3D%3D%20-1)%3B%0Aassert!((-1).div_floor(%26%202)%20%3D%3D%20-1)%3B%0Aassert!((-1).div_floor(%26-2)%20%3D%3D%20%200)%3B%0A%7D">Run</a></pre>
</div><h3 id='tymethod.mod_floor' class='method'><span id='mod_floor.v' class='invisible'><code>fn <a href='#tymethod.mod_floor' class='fnname'>mod_floor</a>(&amp;self, other: &amp;Self) -&gt; Self</code></span></h3><div class='docblock'><p>Floored integer modulo, satisfying:</p>
<pre class="rust rust-example-rendered">
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">n</span>.<span class="ident">div_floor</span>(<span class="kw-2">&amp;</span><span class="ident">d</span>) <span class="op">*</span> <span class="ident">d</span> <span class="op">+</span> <span class="ident">n</span>.<span class="ident">mod_floor</span>(<span class="kw-2">&amp;</span><span class="ident">d</span>) <span class="op">==</span> <span class="ident">n</span>)<a class="test-arrow" target="_blank" href="http://play.integer32.com/?code=extern%20crate%20num_integer%3B%0Afn%20main()%20%7B%0Ause%20num_integer%3A%3AInteger%3B%0Alet%20n%20%3D%201%3B%20let%20d%20%3D%201%3B%0Aassert!(n.div_floor(%26d)%20*%20d%20%2B%20n.mod_floor(%26d)%20%3D%3D%20n)%0A%7D">Run</a></pre>
<h1 id='examples-1' class='section-header'><a href='#examples-1'>Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="macro">assert</span><span class="macro">!</span>(( <span class="number">8</span>).<span class="ident">mod_floor</span>(<span class="op">&amp;</span> <span class="number">3</span>) <span class="op">==</span> <span class="number">2</span>);
<span class="macro">assert</span><span class="macro">!</span>(( <span class="number">8</span>).<span class="ident">mod_floor</span>(<span class="kw-2">&amp;</span><span class="op">-</span><span class="number">3</span>) <span class="op">==</span> <span class="op">-</span><span class="number">1</span>);
<span class="macro">assert</span><span class="macro">!</span>((<span class="op">-</span><span class="number">8</span>).<span class="ident">mod_floor</span>(<span class="op">&amp;</span> <span class="number">3</span>) <span class="op">==</span> <span class="number">1</span>);
<span class="macro">assert</span><span class="macro">!</span>((<span class="op">-</span><span class="number">8</span>).<span class="ident">mod_floor</span>(<span class="kw-2">&amp;</span><span class="op">-</span><span class="number">3</span>) <span class="op">==</span> <span class="op">-</span><span class="number">2</span>);
<span class="macro">assert</span><span class="macro">!</span>(( <span class="number">1</span>).<span class="ident">mod_floor</span>(<span class="op">&amp;</span> <span class="number">2</span>) <span class="op">==</span> <span class="number">1</span>);
<span class="macro">assert</span><span class="macro">!</span>(( <span class="number">1</span>).<span class="ident">mod_floor</span>(<span class="kw-2">&amp;</span><span class="op">-</span><span class="number">2</span>) <span class="op">==</span> <span class="op">-</span><span class="number">1</span>);
<span class="macro">assert</span><span class="macro">!</span>((<span class="op">-</span><span class="number">1</span>).<span class="ident">mod_floor</span>(<span class="op">&amp;</span> <span class="number">2</span>) <span class="op">==</span> <span class="number">1</span>);
<span class="macro">assert</span><span class="macro">!</span>((<span class="op">-</span><span class="number">1</span>).<span class="ident">mod_floor</span>(<span class="kw-2">&amp;</span><span class="op">-</span><span class="number">2</span>) <span class="op">==</span> <span class="op">-</span><span class="number">1</span>);<a class="test-arrow" target="_blank" href="http://play.integer32.com/?code=extern%20crate%20num_integer%3B%0Afn%20main()%20%7B%0Ause%20num_integer%3A%3AInteger%3B%0Aassert!((%208).mod_floor(%26%203)%20%3D%3D%20%202)%3B%0Aassert!((%208).mod_floor(%26-3)%20%3D%3D%20-1)%3B%0Aassert!((-8).mod_floor(%26%203)%20%3D%3D%20%201)%3B%0Aassert!((-8).mod_floor(%26-3)%20%3D%3D%20-2)%3B%0A%0Aassert!((%201).mod_floor(%26%202)%20%3D%3D%20%201)%3B%0Aassert!((%201).mod_floor(%26-2)%20%3D%3D%20-1)%3B%0Aassert!((-1).mod_floor(%26%202)%20%3D%3D%20%201)%3B%0Aassert!((-1).mod_floor(%26-2)%20%3D%3D%20-1)%3B%0A%7D">Run</a></pre>
</div><h3 id='tymethod.gcd' class='method'><span id='gcd.v' class='invisible'><code>fn <a href='#tymethod.gcd' class='fnname'>gcd</a>(&amp;self, other: &amp;Self) -&gt; Self</code></span></h3><div class='docblock'><p>Greatest Common Divisor (GCD).</p>
<h1 id='examples-2' class='section-header'><a href='#examples-2'>Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">6</span>.<span class="ident">gcd</span>(<span class="kw-2">&amp;</span><span class="number">8</span>), <span class="number">2</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">7</span>.<span class="ident">gcd</span>(<span class="kw-2">&amp;</span><span class="number">3</span>), <span class="number">1</span>);<a class="test-arrow" target="_blank" href="http://play.integer32.com/?code=extern%20crate%20num_integer%3B%0Afn%20main()%20%7B%0Ause%20num_integer%3A%3AInteger%3B%0Aassert_eq!(6.gcd(%268)%2C%202)%3B%0Aassert_eq!(7.gcd(%263)%2C%201)%3B%0A%7D">Run</a></pre>
</div><h3 id='tymethod.lcm' class='method'><span id='lcm.v' class='invisible'><code>fn <a href='#tymethod.lcm' class='fnname'>lcm</a>(&amp;self, other: &amp;Self) -&gt; Self</code></span></h3><div class='docblock'><p>Lowest Common Multiple (LCM).</p>
<h1 id='examples-3' class='section-header'><a href='#examples-3'>Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">7</span>.<span class="ident">lcm</span>(<span class="kw-2">&amp;</span><span class="number">3</span>), <span class="number">21</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">2</span>.<span class="ident">lcm</span>(<span class="kw-2">&amp;</span><span class="number">4</span>), <span class="number">4</span>);<a class="test-arrow" target="_blank" href="http://play.integer32.com/?code=extern%20crate%20num_integer%3B%0Afn%20main()%20%7B%0Ause%20num_integer%3A%3AInteger%3B%0Aassert_eq!(7.lcm(%263)%2C%2021)%3B%0Aassert_eq!(2.lcm(%264)%2C%204)%3B%0A%7D">Run</a></pre>
</div><h3 id='tymethod.divides' class='method'><span id='divides.v' class='invisible'><code>fn <a href='#tymethod.divides' class='fnname'>divides</a>(&amp;self, other: &amp;Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></h3><div class='docblock'><p>Deprecated, use <code>is_multiple_of</code> instead.</p>
</div><h3 id='tymethod.is_multiple_of' class='method'><span id='is_multiple_of.v' class='invisible'><code>fn <a href='#tymethod.is_multiple_of' class='fnname'>is_multiple_of</a>(&amp;self, other: &amp;Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></h3><div class='docblock'><p>Returns <code>true</code> if <code>other</code> is a multiple of <code>self</code>.</p>
<h1 id='examples-4' class='section-header'><a href='#examples-4'>Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">9</span>.<span class="ident">is_multiple_of</span>(<span class="kw-2">&amp;</span><span class="number">3</span>), <span class="bool-val">true</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">3</span>.<span class="ident">is_multiple_of</span>(<span class="kw-2">&amp;</span><span class="number">9</span>), <span class="bool-val">false</span>);<a class="test-arrow" target="_blank" href="http://play.integer32.com/?code=extern%20crate%20num_integer%3B%0Afn%20main()%20%7B%0Ause%20num_integer%3A%3AInteger%3B%0Aassert_eq!(9.is_multiple_of(%263)%2C%20true)%3B%0Aassert_eq!(3.is_multiple_of(%269)%2C%20false)%3B%0A%7D">Run</a></pre>
</div><h3 id='tymethod.is_even' class='method'><span id='is_even.v' class='invisible'><code>fn <a href='#tymethod.is_even' class='fnname'>is_even</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></h3><div class='docblock'><p>Returns <code>true</code> if the number is even.</p>
<h1 id='examples-5' class='section-header'><a href='#examples-5'>Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">3</span>.<span class="ident">is_even</span>(), <span class="bool-val">false</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">4</span>.<span class="ident">is_even</span>(), <span class="bool-val">true</span>);<a class="test-arrow" target="_blank" href="http://play.integer32.com/?code=extern%20crate%20num_integer%3B%0Afn%20main()%20%7B%0Ause%20num_integer%3A%3AInteger%3B%0Aassert_eq!(3.is_even()%2C%20false)%3B%0Aassert_eq!(4.is_even()%2C%20true)%3B%0A%7D">Run</a></pre>
</div><h3 id='tymethod.is_odd' class='method'><span id='is_odd.v' class='invisible'><code>fn <a href='#tymethod.is_odd' class='fnname'>is_odd</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></h3><div class='docblock'><p>Returns <code>true</code> if the number is odd.</p>
<h1 id='examples-6' class='section-header'><a href='#examples-6'>Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">3</span>.<span class="ident">is_odd</span>(), <span class="bool-val">true</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">4</span>.<span class="ident">is_odd</span>(), <span class="bool-val">false</span>);<a class="test-arrow" target="_blank" href="http://play.integer32.com/?code=extern%20crate%20num_integer%3B%0Afn%20main()%20%7B%0Ause%20num_integer%3A%3AInteger%3B%0Aassert_eq!(3.is_odd()%2C%20true)%3B%0Aassert_eq!(4.is_odd()%2C%20false)%3B%0A%7D">Run</a></pre>
</div><h3 id='tymethod.div_rem' class='method'><span id='div_rem.v' class='invisible'><code>fn <a href='#tymethod.div_rem' class='fnname'>div_rem</a>(&amp;self, other: &amp;Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>Self, Self<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code></span></h3><div class='docblock'><p>Simultaneous truncated integer division and modulus.
Returns <code>(quotient, remainder)</code>.</p>
<h1 id='examples-7' class='section-header'><a href='#examples-7'>Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="macro">assert_eq</span><span class="macro">!</span>(( <span class="number">8</span>).<span class="ident">div_rem</span>( <span class="kw-2">&amp;</span><span class="number">3</span>), ( <span class="number">2</span>, <span class="number">2</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(( <span class="number">8</span>).<span class="ident">div_rem</span>(<span class="kw-2">&amp;</span><span class="op">-</span><span class="number">3</span>), (<span class="op">-</span><span class="number">2</span>, <span class="number">2</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>((<span class="op">-</span><span class="number">8</span>).<span class="ident">div_rem</span>( <span class="kw-2">&amp;</span><span class="number">3</span>), (<span class="op">-</span><span class="number">2</span>, <span class="op">-</span><span class="number">2</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>((<span class="op">-</span><span class="number">8</span>).<span class="ident">div_rem</span>(<span class="kw-2">&amp;</span><span class="op">-</span><span class="number">3</span>), ( <span class="number">2</span>, <span class="op">-</span><span class="number">2</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(( <span class="number">1</span>).<span class="ident">div_rem</span>( <span class="kw-2">&amp;</span><span class="number">2</span>), ( <span class="number">0</span>, <span class="number">1</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(( <span class="number">1</span>).<span class="ident">div_rem</span>(<span class="kw-2">&amp;</span><span class="op">-</span><span class="number">2</span>), ( <span class="number">0</span>, <span class="number">1</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>((<span class="op">-</span><span class="number">1</span>).<span class="ident">div_rem</span>( <span class="kw-2">&amp;</span><span class="number">2</span>), ( <span class="number">0</span>, <span class="op">-</span><span class="number">1</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>((<span class="op">-</span><span class="number">1</span>).<span class="ident">div_rem</span>(<span class="kw-2">&amp;</span><span class="op">-</span><span class="number">2</span>), ( <span class="number">0</span>, <span class="op">-</span><span class="number">1</span>));<a class="test-arrow" target="_blank" href="http://play.integer32.com/?code=extern%20crate%20num_integer%3B%0Afn%20main()%20%7B%0Ause%20num_integer%3A%3AInteger%3B%0Aassert_eq!((%208).div_rem(%20%263)%2C%20(%202%2C%20%202))%3B%0Aassert_eq!((%208).div_rem(%26-3)%2C%20(-2%2C%20%202))%3B%0Aassert_eq!((-8).div_rem(%20%263)%2C%20(-2%2C%20-2))%3B%0Aassert_eq!((-8).div_rem(%26-3)%2C%20(%202%2C%20-2))%3B%0A%0Aassert_eq!((%201).div_rem(%20%262)%2C%20(%200%2C%20%201))%3B%0Aassert_eq!((%201).div_rem(%26-2)%2C%20(%200%2C%20%201))%3B%0Aassert_eq!((-1).div_rem(%20%262)%2C%20(%200%2C%20-1))%3B%0Aassert_eq!((-1).div_rem(%26-2)%2C%20(%200%2C%20-1))%3B%0A%7D">Run</a></pre>
</div></div>
<h2 id='provided-methods'>Provided Methods</h2>
<div class='methods'>
<h3 id='method.div_mod_floor' class='method'><span id='div_mod_floor.v' class='invisible'><code>fn <a href='#method.div_mod_floor' class='fnname'>div_mod_floor</a>(&amp;self, other: &amp;Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>Self, Self<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code></span></h3><div class='docblock'><p>Simultaneous floored integer division and modulus.
Returns <code>(quotient, remainder)</code>.</p>
<h1 id='examples-8' class='section-header'><a href='#examples-8'>Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="macro">assert_eq</span><span class="macro">!</span>(( <span class="number">8</span>).<span class="ident">div_mod_floor</span>( <span class="kw-2">&amp;</span><span class="number">3</span>), ( <span class="number">2</span>, <span class="number">2</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(( <span class="number">8</span>).<span class="ident">div_mod_floor</span>(<span class="kw-2">&amp;</span><span class="op">-</span><span class="number">3</span>), (<span class="op">-</span><span class="number">3</span>, <span class="op">-</span><span class="number">1</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>((<span class="op">-</span><span class="number">8</span>).<span class="ident">div_mod_floor</span>( <span class="kw-2">&amp;</span><span class="number">3</span>), (<span class="op">-</span><span class="number">3</span>, <span class="number">1</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>((<span class="op">-</span><span class="number">8</span>).<span class="ident">div_mod_floor</span>(<span class="kw-2">&amp;</span><span class="op">-</span><span class="number">3</span>), ( <span class="number">2</span>, <span class="op">-</span><span class="number">2</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(( <span class="number">1</span>).<span class="ident">div_mod_floor</span>( <span class="kw-2">&amp;</span><span class="number">2</span>), ( <span class="number">0</span>, <span class="number">1</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(( <span class="number">1</span>).<span class="ident">div_mod_floor</span>(<span class="kw-2">&amp;</span><span class="op">-</span><span class="number">2</span>), (<span class="op">-</span><span class="number">1</span>, <span class="op">-</span><span class="number">1</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>((<span class="op">-</span><span class="number">1</span>).<span class="ident">div_mod_floor</span>( <span class="kw-2">&amp;</span><span class="number">2</span>), (<span class="op">-</span><span class="number">1</span>, <span class="number">1</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>((<span class="op">-</span><span class="number">1</span>).<span class="ident">div_mod_floor</span>(<span class="kw-2">&amp;</span><span class="op">-</span><span class="number">2</span>), ( <span class="number">0</span>, <span class="op">-</span><span class="number">1</span>));<a class="test-arrow" target="_blank" href="http://play.integer32.com/?code=extern%20crate%20num_integer%3B%0Afn%20main()%20%7B%0Ause%20num_integer%3A%3AInteger%3B%0Aassert_eq!((%208).div_mod_floor(%20%263)%2C%20(%202%2C%20%202))%3B%0Aassert_eq!((%208).div_mod_floor(%26-3)%2C%20(-3%2C%20-1))%3B%0Aassert_eq!((-8).div_mod_floor(%20%263)%2C%20(-3%2C%20%201))%3B%0Aassert_eq!((-8).div_mod_floor(%26-3)%2C%20(%202%2C%20-2))%3B%0A%0Aassert_eq!((%201).div_mod_floor(%20%262)%2C%20(%200%2C%20%201))%3B%0Aassert_eq!((%201).div_mod_floor(%26-2)%2C%20(-1%2C%20-1))%3B%0Aassert_eq!((-1).div_mod_floor(%20%262)%2C%20(-1%2C%20%201))%3B%0Aassert_eq!((-1).div_mod_floor(%26-2)%2C%20(%200%2C%20-1))%3B%0A%7D">Run</a></pre>
</div></div>
<h2 id='implementors'>Implementors</h2>
<ul class='item-list' id='implementors-list'>
<li><code>impl Integer for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a></code></li>
<li><code>impl Integer for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a></code></li>
<li><code>impl Integer for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a></code></li>
<li><code>impl Integer for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a></code></li>
<li><code>impl Integer for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.isize.html">isize</a></code></li>
<li><code>impl Integer for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a></code></li>
<li><code>impl Integer for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a></code></li>
<li><code>impl Integer for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code></li>
<li><code>impl Integer for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></code></li>
<li><code>impl Integer for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code></li>
</ul><script type="text/javascript" async
src="../implementors/num_integer/trait.Integer.js">
</script></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../";
window.currentCrate = "num_integer";
</script>
<script src="../main.js"></script>
<script defer src="../search-index.js"></script>
</body>
</html>