1047 lines
No EOL
143 KiB
HTML
1047 lines
No EOL
143 KiB
HTML
<!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 `Float` trait in crate `num_traits`.">
|
||
<meta name="keywords" content="rust, rustlang, rust-lang, Float">
|
||
|
||
<title>num_traits::float::Float - Rust</title>
|
||
|
||
<link rel="stylesheet" type="text/css" href="../../normalize.css">
|
||
<link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle">
|
||
|
||
<link rel="stylesheet" type="text/css" href="../../dark.css">
|
||
<link rel="stylesheet" type="text/css" href="../../main.css" id="themeStyle">
|
||
<script src="../../storage.js"></script>
|
||
|
||
|
||
|
||
|
||
</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">
|
||
<div class="sidebar-menu">☰</div>
|
||
|
||
<p class='location'>Trait Float</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.nan">nan</a><a href="#tymethod.infinity">infinity</a><a href="#tymethod.neg_infinity">neg_infinity</a><a href="#tymethod.neg_zero">neg_zero</a><a href="#tymethod.min_value">min_value</a><a href="#tymethod.min_positive_value">min_positive_value</a><a href="#tymethod.max_value">max_value</a><a href="#tymethod.is_nan">is_nan</a><a href="#tymethod.is_infinite">is_infinite</a><a href="#tymethod.is_finite">is_finite</a><a href="#tymethod.is_normal">is_normal</a><a href="#tymethod.classify">classify</a><a href="#tymethod.floor">floor</a><a href="#tymethod.ceil">ceil</a><a href="#tymethod.round">round</a><a href="#tymethod.trunc">trunc</a><a href="#tymethod.fract">fract</a><a href="#tymethod.abs">abs</a><a href="#tymethod.signum">signum</a><a href="#tymethod.is_sign_positive">is_sign_positive</a><a href="#tymethod.is_sign_negative">is_sign_negative</a><a href="#tymethod.mul_add">mul_add</a><a href="#tymethod.recip">recip</a><a href="#tymethod.powi">powi</a><a href="#tymethod.powf">powf</a><a href="#tymethod.sqrt">sqrt</a><a href="#tymethod.exp">exp</a><a href="#tymethod.exp2">exp2</a><a href="#tymethod.ln">ln</a><a href="#tymethod.log">log</a><a href="#tymethod.log2">log2</a><a href="#tymethod.log10">log10</a><a href="#tymethod.max">max</a><a href="#tymethod.min">min</a><a href="#tymethod.abs_sub">abs_sub</a><a href="#tymethod.cbrt">cbrt</a><a href="#tymethod.hypot">hypot</a><a href="#tymethod.sin">sin</a><a href="#tymethod.cos">cos</a><a href="#tymethod.tan">tan</a><a href="#tymethod.asin">asin</a><a href="#tymethod.acos">acos</a><a href="#tymethod.atan">atan</a><a href="#tymethod.atan2">atan2</a><a href="#tymethod.sin_cos">sin_cos</a><a href="#tymethod.exp_m1">exp_m1</a><a href="#tymethod.ln_1p">ln_1p</a><a href="#tymethod.sinh">sinh</a><a href="#tymethod.cosh">cosh</a><a href="#tymethod.tanh">tanh</a><a href="#tymethod.asinh">asinh</a><a href="#tymethod.acosh">acosh</a><a href="#tymethod.atanh">atanh</a><a href="#tymethod.integer_decode">integer_decode</a></div><a class="sidebar-title" href="#provided-methods">Provided Methods</a><div class="sidebar-links"><a href="#method.epsilon">epsilon</a><a href="#method.to_degrees">to_degrees</a><a href="#method.to_radians">to_radians</a></div><a class="sidebar-title" href="#foreign-impls">Implementations on Foreign Types</a><div class="sidebar-links"><a href="#impl-Float">f32</a><a href="#impl-Float">f64</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class='location'><a href='../index.html'>num_traits</a>::<wbr><a href='index.html'>float</a></p><script>window.sidebarCurrent = {name: 'Float', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></script></div>
|
||
</nav>
|
||
|
||
<div class="theme-picker">
|
||
<button id="theme-picker" aria-label="Pick another theme!">
|
||
<img src="../../brush.svg" width="18" alt="Pick another theme!">
|
||
</button>
|
||
<div id="theme-choices"></div>
|
||
</div>
|
||
<script src="../../theme.js"></script>
|
||
<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_traits</a>::<wbr><a href='index.html'>float</a>::<wbr><a class="trait" href=''>Float</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'>−</span>]
|
||
</a>
|
||
</span><a class='srclink' href='../../src/num_traits/float.rs.html#890-1801' title='goto source code'>[src]</a></span></h1>
|
||
<pre class='rust trait'>pub trait Float: <a class="trait" href="../../num_traits/cast/trait.NumCast.html" title="trait num_traits::cast::NumCast">NumCast</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/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/arith/trait.Neg.html" title="trait core::ops::arith::Neg">Neg</a><Output = Self> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a><Self> {
|
||
fn <a href='#tymethod.nan' class='fnname'>nan</a>() -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.infinity' class='fnname'>infinity</a>() -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.neg_infinity' class='fnname'>neg_infinity</a>() -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.neg_zero' class='fnname'>neg_zero</a>() -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.min_value' class='fnname'>min_value</a>() -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.min_positive_value' class='fnname'>min_positive_value</a>() -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.max_value' class='fnname'>max_value</a>() -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.is_nan' class='fnname'>is_nan</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.is_infinite' class='fnname'>is_infinite</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.is_finite' class='fnname'>is_finite</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.is_normal' class='fnname'>is_normal</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.classify' class='fnname'>classify</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/num/enum.FpCategory.html" title="enum core::num::FpCategory">FpCategory</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.floor' class='fnname'>floor</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.ceil' class='fnname'>ceil</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.round' class='fnname'>round</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.trunc' class='fnname'>trunc</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.fract' class='fnname'>fract</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.abs' class='fnname'>abs</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.signum' class='fnname'>signum</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.is_sign_positive' class='fnname'>is_sign_positive</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.is_sign_negative' class='fnname'>is_sign_negative</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.mul_add' class='fnname'>mul_add</a>(self, a: Self, b: Self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.recip' class='fnname'>recip</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.powi' class='fnname'>powi</a>(self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.powf' class='fnname'>powf</a>(self, n: Self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.sqrt' class='fnname'>sqrt</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.exp' class='fnname'>exp</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.exp2' class='fnname'>exp2</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.ln' class='fnname'>ln</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.log' class='fnname'>log</a>(self, base: Self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.log2' class='fnname'>log2</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.log10' class='fnname'>log10</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.max' class='fnname'>max</a>(self, other: Self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.min' class='fnname'>min</a>(self, other: Self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.abs_sub' class='fnname'>abs_sub</a>(self, other: Self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.cbrt' class='fnname'>cbrt</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.hypot' class='fnname'>hypot</a>(self, other: Self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.sin' class='fnname'>sin</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.cos' class='fnname'>cos</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.tan' class='fnname'>tan</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.asin' class='fnname'>asin</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.acos' class='fnname'>acos</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.atan' class='fnname'>atan</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.atan2' class='fnname'>atan2</a>(self, other: Self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.sin_cos' class='fnname'>sin_cos</a>(self) -> <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>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.exp_m1' class='fnname'>exp_m1</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.ln_1p' class='fnname'>ln_1p</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.sinh' class='fnname'>sinh</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.cosh' class='fnname'>cosh</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.tanh' class='fnname'>tanh</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.asinh' class='fnname'>asinh</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.acosh' class='fnname'>acosh</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.atanh' class='fnname'>atanh</a>(self) -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.integer_decode' class='fnname'>integer_decode</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>;
|
||
|
||
fn <a href='#method.epsilon' class='fnname'>epsilon</a>() -> Self { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.to_degrees' class='fnname'>to_degrees</a>(self) -> Self { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.to_radians' class='fnname'>to_radians</a>(self) -> Self { ... }
|
||
}</pre><div class='docblock'><p>Generic trait for floating point numbers</p>
|
||
<p>This trait is only available with the <code>std</code> feature.</p>
|
||
</div>
|
||
<h2 id='required-methods' class='small-section-header'>
|
||
Required Methods<a href='#required-methods' class='anchor'></a>
|
||
</h2>
|
||
<div class='methods'>
|
||
<h3 id='tymethod.nan' class='method'><span id='nan.v' class='invisible'><code>fn <a href='#tymethod.nan' class='fnname'>nan</a>() -> Self</code></span></h3><div class='docblock'><p>Returns the <code>NaN</code> value.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">nan</span>: <span class="ident">f32</span> <span class="op">=</span> <span class="ident">Float</span>::<span class="ident">nan</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">nan</span>.<span class="ident">is_nan</span>());</pre>
|
||
</div><h3 id='tymethod.infinity' class='method'><span id='infinity.v' class='invisible'><code>fn <a href='#tymethod.infinity' class='fnname'>infinity</a>() -> Self</code></span></h3><div class='docblock'><p>Returns the infinite value.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f32</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">infinity</span>: <span class="ident">f32</span> <span class="op">=</span> <span class="ident">Float</span>::<span class="ident">infinity</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">infinity</span>.<span class="ident">is_infinite</span>());
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">infinity</span>.<span class="ident">is_finite</span>());
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">infinity</span> <span class="op">></span> <span class="ident">f32</span>::<span class="ident">MAX</span>);</pre>
|
||
</div><h3 id='tymethod.neg_infinity' class='method'><span id='neg_infinity.v' class='invisible'><code>fn <a href='#tymethod.neg_infinity' class='fnname'>neg_infinity</a>() -> Self</code></span></h3><div class='docblock'><p>Returns the negative infinite value.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f32</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">neg_infinity</span>: <span class="ident">f32</span> <span class="op">=</span> <span class="ident">Float</span>::<span class="ident">neg_infinity</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">neg_infinity</span>.<span class="ident">is_infinite</span>());
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">neg_infinity</span>.<span class="ident">is_finite</span>());
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">neg_infinity</span> <span class="op"><</span> <span class="ident">f32</span>::<span class="ident">MIN</span>);</pre>
|
||
</div><h3 id='tymethod.neg_zero' class='method'><span id='neg_zero.v' class='invisible'><code>fn <a href='#tymethod.neg_zero' class='fnname'>neg_zero</a>() -> Self</code></span></h3><div class='docblock'><p>Returns <code>-0.0</code>.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::{<span class="ident">Zero</span>, <span class="ident">Float</span>};
|
||
|
||
<span class="kw">let</span> <span class="ident">inf</span>: <span class="ident">f32</span> <span class="op">=</span> <span class="ident">Float</span>::<span class="ident">infinity</span>();
|
||
<span class="kw">let</span> <span class="ident">zero</span>: <span class="ident">f32</span> <span class="op">=</span> <span class="ident">Zero</span>::<span class="ident">zero</span>();
|
||
<span class="kw">let</span> <span class="ident">neg_zero</span>: <span class="ident">f32</span> <span class="op">=</span> <span class="ident">Float</span>::<span class="ident">neg_zero</span>();
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">zero</span>, <span class="ident">neg_zero</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">7.0f32</span><span class="op">/</span><span class="ident">inf</span>, <span class="ident">zero</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">zero</span> <span class="op">*</span> <span class="number">10.0</span>, <span class="ident">zero</span>);</pre>
|
||
</div><h3 id='tymethod.min_value' class='method'><span id='min_value.v' class='invisible'><code>fn <a href='#tymethod.min_value' class='fnname'>min_value</a>() -> Self</code></span></h3><div class='docblock'><p>Returns the smallest finite value that this type can represent.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span>: <span class="ident">f64</span> <span class="op">=</span> <span class="ident">Float</span>::<span class="ident">min_value</span>();
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">x</span>, <span class="ident">f64</span>::<span class="ident">MIN</span>);</pre>
|
||
</div><h3 id='tymethod.min_positive_value' class='method'><span id='min_positive_value.v' class='invisible'><code>fn <a href='#tymethod.min_positive_value' class='fnname'>min_positive_value</a>() -> Self</code></span></h3><div class='docblock'><p>Returns the smallest positive, normalized value that this type can represent.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span>: <span class="ident">f64</span> <span class="op">=</span> <span class="ident">Float</span>::<span class="ident">min_positive_value</span>();
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">x</span>, <span class="ident">f64</span>::<span class="ident">MIN_POSITIVE</span>);</pre>
|
||
</div><h3 id='tymethod.max_value' class='method'><span id='max_value.v' class='invisible'><code>fn <a href='#tymethod.max_value' class='fnname'>max_value</a>() -> Self</code></span></h3><div class='docblock'><p>Returns the largest finite value that this type can represent.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span>: <span class="ident">f64</span> <span class="op">=</span> <span class="ident">Float</span>::<span class="ident">max_value</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">x</span>, <span class="ident">f64</span>::<span class="ident">MAX</span>);</pre>
|
||
</div><h3 id='tymethod.is_nan' class='method'><span id='is_nan.v' class='invisible'><code>fn <a href='#tymethod.is_nan' class='fnname'>is_nan</a>(self) -> <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 this value is <code>NaN</code> and false otherwise.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">nan</span> <span class="op">=</span> <span class="ident">f64</span>::<span class="ident">NAN</span>;
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="number">7.0</span>;
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">nan</span>.<span class="ident">is_nan</span>());
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">f</span>.<span class="ident">is_nan</span>());</pre>
|
||
</div><h3 id='tymethod.is_infinite' class='method'><span id='is_infinite.v' class='invisible'><code>fn <a href='#tymethod.is_infinite' class='fnname'>is_infinite</a>(self) -> <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 this value is positive infinity or negative infinity and
|
||
false otherwise.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f32</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="number">7.0f32</span>;
|
||
<span class="kw">let</span> <span class="ident">inf</span>: <span class="ident">f32</span> <span class="op">=</span> <span class="ident">Float</span>::<span class="ident">infinity</span>();
|
||
<span class="kw">let</span> <span class="ident">neg_inf</span>: <span class="ident">f32</span> <span class="op">=</span> <span class="ident">Float</span>::<span class="ident">neg_infinity</span>();
|
||
<span class="kw">let</span> <span class="ident">nan</span>: <span class="ident">f32</span> <span class="op">=</span> <span class="ident">f32</span>::<span class="ident">NAN</span>;
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">f</span>.<span class="ident">is_infinite</span>());
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">nan</span>.<span class="ident">is_infinite</span>());
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">inf</span>.<span class="ident">is_infinite</span>());
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">neg_inf</span>.<span class="ident">is_infinite</span>());</pre>
|
||
</div><h3 id='tymethod.is_finite' class='method'><span id='is_finite.v' class='invisible'><code>fn <a href='#tymethod.is_finite' class='fnname'>is_finite</a>(self) -> <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 this number is neither infinite nor <code>NaN</code>.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f32</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="number">7.0f32</span>;
|
||
<span class="kw">let</span> <span class="ident">inf</span>: <span class="ident">f32</span> <span class="op">=</span> <span class="ident">Float</span>::<span class="ident">infinity</span>();
|
||
<span class="kw">let</span> <span class="ident">neg_inf</span>: <span class="ident">f32</span> <span class="op">=</span> <span class="ident">Float</span>::<span class="ident">neg_infinity</span>();
|
||
<span class="kw">let</span> <span class="ident">nan</span>: <span class="ident">f32</span> <span class="op">=</span> <span class="ident">f32</span>::<span class="ident">NAN</span>;
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">f</span>.<span class="ident">is_finite</span>());
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">nan</span>.<span class="ident">is_finite</span>());
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">inf</span>.<span class="ident">is_finite</span>());
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">neg_inf</span>.<span class="ident">is_finite</span>());</pre>
|
||
</div><h3 id='tymethod.is_normal' class='method'><span id='is_normal.v' class='invisible'><code>fn <a href='#tymethod.is_normal' class='fnname'>is_normal</a>(self) -> <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 neither zero, infinite,
|
||
<a href="http://en.wikipedia.org/wiki/Denormal_number">subnormal</a>, or <code>NaN</code>.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f32</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">min</span> <span class="op">=</span> <span class="ident">f32</span>::<span class="ident">MIN_POSITIVE</span>; <span class="comment">// 1.17549435e-38f32</span>
|
||
<span class="kw">let</span> <span class="ident">max</span> <span class="op">=</span> <span class="ident">f32</span>::<span class="ident">MAX</span>;
|
||
<span class="kw">let</span> <span class="ident">lower_than_min</span> <span class="op">=</span> <span class="number">1.0e-40_f32</span>;
|
||
<span class="kw">let</span> <span class="ident">zero</span> <span class="op">=</span> <span class="number">0.0f32</span>;
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">min</span>.<span class="ident">is_normal</span>());
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">max</span>.<span class="ident">is_normal</span>());
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">zero</span>.<span class="ident">is_normal</span>());
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">f32</span>::<span class="ident">NAN</span>.<span class="ident">is_normal</span>());
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">f32</span>::<span class="ident">INFINITY</span>.<span class="ident">is_normal</span>());
|
||
<span class="comment">// Values between `0` and `min` are Subnormal.</span>
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">lower_than_min</span>.<span class="ident">is_normal</span>());</pre>
|
||
</div><h3 id='tymethod.classify' class='method'><span id='classify.v' class='invisible'><code>fn <a href='#tymethod.classify' class='fnname'>classify</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/num/enum.FpCategory.html" title="enum core::num::FpCategory">FpCategory</a></code></span></h3><div class='docblock'><p>Returns the floating point category of the number. If only one property
|
||
is going to be tested, it is generally faster to use the specific
|
||
predicate instead.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">num</span>::<span class="ident">FpCategory</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f32</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">num</span> <span class="op">=</span> <span class="number">12.4f32</span>;
|
||
<span class="kw">let</span> <span class="ident">inf</span> <span class="op">=</span> <span class="ident">f32</span>::<span class="ident">INFINITY</span>;
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">num</span>.<span class="ident">classify</span>(), <span class="ident">FpCategory</span>::<span class="ident">Normal</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">inf</span>.<span class="ident">classify</span>(), <span class="ident">FpCategory</span>::<span class="ident">Infinite</span>);</pre>
|
||
</div><h3 id='tymethod.floor' class='method'><span id='floor.v' class='invisible'><code>fn <a href='#tymethod.floor' class='fnname'>floor</a>(self) -> Self</code></span></h3><div class='docblock'><p>Returns the largest integer less than or equal to a number.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="number">3.99</span>;
|
||
<span class="kw">let</span> <span class="ident">g</span> <span class="op">=</span> <span class="number">3.0</span>;
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">f</span>.<span class="ident">floor</span>(), <span class="number">3.0</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">g</span>.<span class="ident">floor</span>(), <span class="number">3.0</span>);</pre>
|
||
</div><h3 id='tymethod.ceil' class='method'><span id='ceil.v' class='invisible'><code>fn <a href='#tymethod.ceil' class='fnname'>ceil</a>(self) -> Self</code></span></h3><div class='docblock'><p>Returns the smallest integer greater than or equal to a number.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="number">3.01</span>;
|
||
<span class="kw">let</span> <span class="ident">g</span> <span class="op">=</span> <span class="number">4.0</span>;
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">f</span>.<span class="ident">ceil</span>(), <span class="number">4.0</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">g</span>.<span class="ident">ceil</span>(), <span class="number">4.0</span>);</pre>
|
||
</div><h3 id='tymethod.round' class='method'><span id='round.v' class='invisible'><code>fn <a href='#tymethod.round' class='fnname'>round</a>(self) -> Self</code></span></h3><div class='docblock'><p>Returns the nearest integer to a number. Round half-way cases away from
|
||
<code>0.0</code>.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="number">3.3</span>;
|
||
<span class="kw">let</span> <span class="ident">g</span> <span class="op">=</span> <span class="op">-</span><span class="number">3.3</span>;
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">f</span>.<span class="ident">round</span>(), <span class="number">3.0</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">g</span>.<span class="ident">round</span>(), <span class="op">-</span><span class="number">3.0</span>);</pre>
|
||
</div><h3 id='tymethod.trunc' class='method'><span id='trunc.v' class='invisible'><code>fn <a href='#tymethod.trunc' class='fnname'>trunc</a>(self) -> Self</code></span></h3><div class='docblock'><p>Return the integer part of a number.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="number">3.3</span>;
|
||
<span class="kw">let</span> <span class="ident">g</span> <span class="op">=</span> <span class="op">-</span><span class="number">3.7</span>;
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">f</span>.<span class="ident">trunc</span>(), <span class="number">3.0</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">g</span>.<span class="ident">trunc</span>(), <span class="op">-</span><span class="number">3.0</span>);</pre>
|
||
</div><h3 id='tymethod.fract' class='method'><span id='fract.v' class='invisible'><code>fn <a href='#tymethod.fract' class='fnname'>fract</a>(self) -> Self</code></span></h3><div class='docblock'><p>Returns the fractional part of a number.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">3.5</span>;
|
||
<span class="kw">let</span> <span class="ident">y</span> <span class="op">=</span> <span class="op">-</span><span class="number">3.5</span>;
|
||
<span class="kw">let</span> <span class="ident">abs_difference_x</span> <span class="op">=</span> (<span class="ident">x</span>.<span class="ident">fract</span>() <span class="op">-</span> <span class="number">0.5</span>).<span class="ident">abs</span>();
|
||
<span class="kw">let</span> <span class="ident">abs_difference_y</span> <span class="op">=</span> (<span class="ident">y</span>.<span class="ident">fract</span>() <span class="op">-</span> (<span class="op">-</span><span class="number">0.5</span>)).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference_x</span> <span class="op"><</span> <span class="number">1e-10</span>);
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference_y</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.abs' class='method'><span id='abs.v' class='invisible'><code>fn <a href='#tymethod.abs' class='fnname'>abs</a>(self) -> Self</code></span></h3><div class='docblock'><p>Computes the absolute value of <code>self</code>. Returns <code>Float::nan()</code> if the
|
||
number is <code>Float::nan()</code>.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">3.5</span>;
|
||
<span class="kw">let</span> <span class="ident">y</span> <span class="op">=</span> <span class="op">-</span><span class="number">3.5</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">abs_difference_x</span> <span class="op">=</span> (<span class="ident">x</span>.<span class="ident">abs</span>() <span class="op">-</span> <span class="ident">x</span>).<span class="ident">abs</span>();
|
||
<span class="kw">let</span> <span class="ident">abs_difference_y</span> <span class="op">=</span> (<span class="ident">y</span>.<span class="ident">abs</span>() <span class="op">-</span> (<span class="op">-</span><span class="ident">y</span>)).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference_x</span> <span class="op"><</span> <span class="number">1e-10</span>);
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference_y</span> <span class="op"><</span> <span class="number">1e-10</span>);
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">f64</span>::<span class="ident">NAN</span>.<span class="ident">abs</span>().<span class="ident">is_nan</span>());</pre>
|
||
</div><h3 id='tymethod.signum' class='method'><span id='signum.v' class='invisible'><code>fn <a href='#tymethod.signum' class='fnname'>signum</a>(self) -> Self</code></span></h3><div class='docblock'><p>Returns a number that represents the sign of <code>self</code>.</p>
|
||
<ul>
|
||
<li><code>1.0</code> if the number is positive, <code>+0.0</code> or <code>Float::infinity()</code></li>
|
||
<li><code>-1.0</code> if the number is negative, <code>-0.0</code> or <code>Float::neg_infinity()</code></li>
|
||
<li><code>Float::nan()</code> if the number is <code>Float::nan()</code></li>
|
||
</ul>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="number">3.5</span>;
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">f</span>.<span class="ident">signum</span>(), <span class="number">1.0</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">f64</span>::<span class="ident">NEG_INFINITY</span>.<span class="ident">signum</span>(), <span class="op">-</span><span class="number">1.0</span>);
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">f64</span>::<span class="ident">NAN</span>.<span class="ident">signum</span>().<span class="ident">is_nan</span>());</pre>
|
||
</div><h3 id='tymethod.is_sign_positive' class='method'><span id='is_sign_positive.v' class='invisible'><code>fn <a href='#tymethod.is_sign_positive' class='fnname'>is_sign_positive</a>(self) -> <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>self</code> is positive, including <code>+0.0</code>,
|
||
<code>Float::infinity()</code>, and since Rust 1.20 also <code>Float::nan()</code>.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">neg_nan</span>: <span class="ident">f64</span> <span class="op">=</span> <span class="op">-</span><span class="ident">f64</span>::<span class="ident">NAN</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="number">7.0</span>;
|
||
<span class="kw">let</span> <span class="ident">g</span> <span class="op">=</span> <span class="op">-</span><span class="number">7.0</span>;
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">f</span>.<span class="ident">is_sign_positive</span>());
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">g</span>.<span class="ident">is_sign_positive</span>());
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">neg_nan</span>.<span class="ident">is_sign_positive</span>());</pre>
|
||
</div><h3 id='tymethod.is_sign_negative' class='method'><span id='is_sign_negative.v' class='invisible'><code>fn <a href='#tymethod.is_sign_negative' class='fnname'>is_sign_negative</a>(self) -> <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>self</code> is negative, including <code>-0.0</code>,
|
||
<code>Float::neg_infinity()</code>, and since Rust 1.20 also <code>-Float::nan()</code>.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">nan</span>: <span class="ident">f64</span> <span class="op">=</span> <span class="ident">f64</span>::<span class="ident">NAN</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="number">7.0</span>;
|
||
<span class="kw">let</span> <span class="ident">g</span> <span class="op">=</span> <span class="op">-</span><span class="number">7.0</span>;
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">f</span>.<span class="ident">is_sign_negative</span>());
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">g</span>.<span class="ident">is_sign_negative</span>());
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">nan</span>.<span class="ident">is_sign_negative</span>());</pre>
|
||
</div><h3 id='tymethod.mul_add' class='method'><span id='mul_add.v' class='invisible'><code>fn <a href='#tymethod.mul_add' class='fnname'>mul_add</a>(self, a: Self, b: Self) -> Self</code></span></h3><div class='docblock'><p>Fused multiply-add. Computes <code>(self * a) + b</code> with only one rounding
|
||
error, yielding a more accurate result than an unfused multiply-add.</p>
|
||
<p>Using <code>mul_add</code> can be more performant than an unfused multiply-add if
|
||
the target architecture has a dedicated <code>fma</code> CPU instruction.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="number">10.0</span>;
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">4.0</span>;
|
||
<span class="kw">let</span> <span class="ident">b</span> <span class="op">=</span> <span class="number">60.0</span>;
|
||
|
||
<span class="comment">// 100.0</span>
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">m</span>.<span class="ident">mul_add</span>(<span class="ident">x</span>, <span class="ident">b</span>) <span class="op">-</span> (<span class="ident">m</span><span class="kw-2">*</span><span class="ident">x</span> <span class="op">+</span> <span class="ident">b</span>)).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.recip' class='method'><span id='recip.v' class='invisible'><code>fn <a href='#tymethod.recip' class='fnname'>recip</a>(self) -> Self</code></span></h3><div class='docblock'><p>Take the reciprocal (inverse) of a number, <code>1/x</code>.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">2.0</span>;
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">x</span>.<span class="ident">recip</span>() <span class="op">-</span> (<span class="number">1.0</span><span class="op">/</span><span class="ident">x</span>)).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.powi' class='method'><span id='powi.v' class='invisible'><code>fn <a href='#tymethod.powi' class='fnname'>powi</a>(self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) -> Self</code></span></h3><div class='docblock'><p>Raise a number to an integer power.</p>
|
||
<p>Using this function is generally faster than using <code>powf</code></p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">2.0</span>;
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">x</span>.<span class="ident">powi</span>(<span class="number">2</span>) <span class="op">-</span> <span class="ident">x</span><span class="kw-2">*</span><span class="ident">x</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.powf' class='method'><span id='powf.v' class='invisible'><code>fn <a href='#tymethod.powf' class='fnname'>powf</a>(self, n: Self) -> Self</code></span></h3><div class='docblock'><p>Raise a number to a floating point power.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">2.0</span>;
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">x</span>.<span class="ident">powf</span>(<span class="number">2.0</span>) <span class="op">-</span> <span class="ident">x</span><span class="kw-2">*</span><span class="ident">x</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.sqrt' class='method'><span id='sqrt.v' class='invisible'><code>fn <a href='#tymethod.sqrt' class='fnname'>sqrt</a>(self) -> Self</code></span></h3><div class='docblock'><p>Take the square root of a number.</p>
|
||
<p>Returns NaN if <code>self</code> is a negative number.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">positive</span> <span class="op">=</span> <span class="number">4.0</span>;
|
||
<span class="kw">let</span> <span class="ident">negative</span> <span class="op">=</span> <span class="op">-</span><span class="number">4.0</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">positive</span>.<span class="ident">sqrt</span>() <span class="op">-</span> <span class="number">2.0</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">negative</span>.<span class="ident">sqrt</span>().<span class="ident">is_nan</span>());</pre>
|
||
</div><h3 id='tymethod.exp' class='method'><span id='exp.v' class='invisible'><code>fn <a href='#tymethod.exp' class='fnname'>exp</a>(self) -> Self</code></span></h3><div class='docblock'><p>Returns <code>e^(self)</code>, (the exponential function).</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">one</span> <span class="op">=</span> <span class="number">1.0</span>;
|
||
<span class="comment">// e^1</span>
|
||
<span class="kw">let</span> <span class="ident">e</span> <span class="op">=</span> <span class="ident">one</span>.<span class="ident">exp</span>();
|
||
|
||
<span class="comment">// ln(e) - 1 == 0</span>
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">e</span>.<span class="ident">ln</span>() <span class="op">-</span> <span class="number">1.0</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.exp2' class='method'><span id='exp2.v' class='invisible'><code>fn <a href='#tymethod.exp2' class='fnname'>exp2</a>(self) -> Self</code></span></h3><div class='docblock'><p>Returns <code>2^(self)</code>.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="number">2.0</span>;
|
||
|
||
<span class="comment">// 2^2 - 4 == 0</span>
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">f</span>.<span class="ident">exp2</span>() <span class="op">-</span> <span class="number">4.0</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.ln' class='method'><span id='ln.v' class='invisible'><code>fn <a href='#tymethod.ln' class='fnname'>ln</a>(self) -> Self</code></span></h3><div class='docblock'><p>Returns the natural logarithm of the number.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">one</span> <span class="op">=</span> <span class="number">1.0</span>;
|
||
<span class="comment">// e^1</span>
|
||
<span class="kw">let</span> <span class="ident">e</span> <span class="op">=</span> <span class="ident">one</span>.<span class="ident">exp</span>();
|
||
|
||
<span class="comment">// ln(e) - 1 == 0</span>
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">e</span>.<span class="ident">ln</span>() <span class="op">-</span> <span class="number">1.0</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.log' class='method'><span id='log.v' class='invisible'><code>fn <a href='#tymethod.log' class='fnname'>log</a>(self, base: Self) -> Self</code></span></h3><div class='docblock'><p>Returns the logarithm of the number with respect to an arbitrary base.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">ten</span> <span class="op">=</span> <span class="number">10.0</span>;
|
||
<span class="kw">let</span> <span class="ident">two</span> <span class="op">=</span> <span class="number">2.0</span>;
|
||
|
||
<span class="comment">// log10(10) - 1 == 0</span>
|
||
<span class="kw">let</span> <span class="ident">abs_difference_10</span> <span class="op">=</span> (<span class="ident">ten</span>.<span class="ident">log</span>(<span class="number">10.0</span>) <span class="op">-</span> <span class="number">1.0</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="comment">// log2(2) - 1 == 0</span>
|
||
<span class="kw">let</span> <span class="ident">abs_difference_2</span> <span class="op">=</span> (<span class="ident">two</span>.<span class="ident">log</span>(<span class="number">2.0</span>) <span class="op">-</span> <span class="number">1.0</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference_10</span> <span class="op"><</span> <span class="number">1e-10</span>);
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference_2</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.log2' class='method'><span id='log2.v' class='invisible'><code>fn <a href='#tymethod.log2' class='fnname'>log2</a>(self) -> Self</code></span></h3><div class='docblock'><p>Returns the base 2 logarithm of the number.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">two</span> <span class="op">=</span> <span class="number">2.0</span>;
|
||
|
||
<span class="comment">// log2(2) - 1 == 0</span>
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">two</span>.<span class="ident">log2</span>() <span class="op">-</span> <span class="number">1.0</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.log10' class='method'><span id='log10.v' class='invisible'><code>fn <a href='#tymethod.log10' class='fnname'>log10</a>(self) -> Self</code></span></h3><div class='docblock'><p>Returns the base 10 logarithm of the number.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">ten</span> <span class="op">=</span> <span class="number">10.0</span>;
|
||
|
||
<span class="comment">// log10(10) - 1 == 0</span>
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">ten</span>.<span class="ident">log10</span>() <span class="op">-</span> <span class="number">1.0</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.max' class='method'><span id='max.v' class='invisible'><code>fn <a href='#tymethod.max' class='fnname'>max</a>(self, other: Self) -> Self</code></span></h3><div class='docblock'><p>Returns the maximum of the two numbers.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">1.0</span>;
|
||
<span class="kw">let</span> <span class="ident">y</span> <span class="op">=</span> <span class="number">2.0</span>;
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">x</span>.<span class="ident">max</span>(<span class="ident">y</span>), <span class="ident">y</span>);</pre>
|
||
</div><h3 id='tymethod.min' class='method'><span id='min.v' class='invisible'><code>fn <a href='#tymethod.min' class='fnname'>min</a>(self, other: Self) -> Self</code></span></h3><div class='docblock'><p>Returns the minimum of the two numbers.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">1.0</span>;
|
||
<span class="kw">let</span> <span class="ident">y</span> <span class="op">=</span> <span class="number">2.0</span>;
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">x</span>.<span class="ident">min</span>(<span class="ident">y</span>), <span class="ident">x</span>);</pre>
|
||
</div><h3 id='tymethod.abs_sub' class='method'><span id='abs_sub.v' class='invisible'><code>fn <a href='#tymethod.abs_sub' class='fnname'>abs_sub</a>(self, other: Self) -> Self</code></span></h3><div class='docblock'><p>The positive difference of two numbers.</p>
|
||
<ul>
|
||
<li>If <code>self <= other</code>: <code>0:0</code></li>
|
||
<li>Else: <code>self - other</code></li>
|
||
</ul>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">3.0</span>;
|
||
<span class="kw">let</span> <span class="ident">y</span> <span class="op">=</span> <span class="op">-</span><span class="number">3.0</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">abs_difference_x</span> <span class="op">=</span> (<span class="ident">x</span>.<span class="ident">abs_sub</span>(<span class="number">1.0</span>) <span class="op">-</span> <span class="number">2.0</span>).<span class="ident">abs</span>();
|
||
<span class="kw">let</span> <span class="ident">abs_difference_y</span> <span class="op">=</span> (<span class="ident">y</span>.<span class="ident">abs_sub</span>(<span class="number">1.0</span>) <span class="op">-</span> <span class="number">0.0</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference_x</span> <span class="op"><</span> <span class="number">1e-10</span>);
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference_y</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.cbrt' class='method'><span id='cbrt.v' class='invisible'><code>fn <a href='#tymethod.cbrt' class='fnname'>cbrt</a>(self) -> Self</code></span></h3><div class='docblock'><p>Take the cubic root of a number.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">8.0</span>;
|
||
|
||
<span class="comment">// x^(1/3) - 2 == 0</span>
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">x</span>.<span class="ident">cbrt</span>() <span class="op">-</span> <span class="number">2.0</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.hypot' class='method'><span id='hypot.v' class='invisible'><code>fn <a href='#tymethod.hypot' class='fnname'>hypot</a>(self, other: Self) -> Self</code></span></h3><div class='docblock'><p>Calculate the length of the hypotenuse of a right-angle triangle given
|
||
legs of length <code>x</code> and <code>y</code>.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">2.0</span>;
|
||
<span class="kw">let</span> <span class="ident">y</span> <span class="op">=</span> <span class="number">3.0</span>;
|
||
|
||
<span class="comment">// sqrt(x^2 + y^2)</span>
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">x</span>.<span class="ident">hypot</span>(<span class="ident">y</span>) <span class="op">-</span> (<span class="ident">x</span>.<span class="ident">powi</span>(<span class="number">2</span>) <span class="op">+</span> <span class="ident">y</span>.<span class="ident">powi</span>(<span class="number">2</span>)).<span class="ident">sqrt</span>()).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.sin' class='method'><span id='sin.v' class='invisible'><code>fn <a href='#tymethod.sin' class='fnname'>sin</a>(self) -> Self</code></span></h3><div class='docblock'><p>Computes the sine of a number (in radians).</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="ident">f64</span>::<span class="ident">consts</span>::<span class="ident">PI</span><span class="op">/</span><span class="number">2.0</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">x</span>.<span class="ident">sin</span>() <span class="op">-</span> <span class="number">1.0</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.cos' class='method'><span id='cos.v' class='invisible'><code>fn <a href='#tymethod.cos' class='fnname'>cos</a>(self) -> Self</code></span></h3><div class='docblock'><p>Computes the cosine of a number (in radians).</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">2.0</span><span class="kw-2">*</span><span class="ident">f64</span>::<span class="ident">consts</span>::<span class="ident">PI</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">x</span>.<span class="ident">cos</span>() <span class="op">-</span> <span class="number">1.0</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.tan' class='method'><span id='tan.v' class='invisible'><code>fn <a href='#tymethod.tan' class='fnname'>tan</a>(self) -> Self</code></span></h3><div class='docblock'><p>Computes the tangent of a number (in radians).</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="ident">f64</span>::<span class="ident">consts</span>::<span class="ident">PI</span><span class="op">/</span><span class="number">4.0</span>;
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">x</span>.<span class="ident">tan</span>() <span class="op">-</span> <span class="number">1.0</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-14</span>);</pre>
|
||
</div><h3 id='tymethod.asin' class='method'><span id='asin.v' class='invisible'><code>fn <a href='#tymethod.asin' class='fnname'>asin</a>(self) -> Self</code></span></h3><div class='docblock'><p>Computes the arcsine of a number. Return value is in radians in
|
||
the range [-pi/2, pi/2] or NaN if the number is outside the range
|
||
[-1, 1].</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">f64</span>::<span class="ident">consts</span>::<span class="ident">PI</span> <span class="op">/</span> <span class="number">2.0</span>;
|
||
|
||
<span class="comment">// asin(sin(pi/2))</span>
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">f</span>.<span class="ident">sin</span>().<span class="ident">asin</span>() <span class="op">-</span> <span class="ident">f64</span>::<span class="ident">consts</span>::<span class="ident">PI</span> <span class="op">/</span> <span class="number">2.0</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.acos' class='method'><span id='acos.v' class='invisible'><code>fn <a href='#tymethod.acos' class='fnname'>acos</a>(self) -> Self</code></span></h3><div class='docblock'><p>Computes the arccosine of a number. Return value is in radians in
|
||
the range [0, pi] or NaN if the number is outside the range
|
||
[-1, 1].</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">f64</span>::<span class="ident">consts</span>::<span class="ident">PI</span> <span class="op">/</span> <span class="number">4.0</span>;
|
||
|
||
<span class="comment">// acos(cos(pi/4))</span>
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">f</span>.<span class="ident">cos</span>().<span class="ident">acos</span>() <span class="op">-</span> <span class="ident">f64</span>::<span class="ident">consts</span>::<span class="ident">PI</span> <span class="op">/</span> <span class="number">4.0</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.atan' class='method'><span id='atan.v' class='invisible'><code>fn <a href='#tymethod.atan' class='fnname'>atan</a>(self) -> Self</code></span></h3><div class='docblock'><p>Computes the arctangent of a number. Return value is in radians in the
|
||
range [-pi/2, pi/2];</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="number">1.0</span>;
|
||
|
||
<span class="comment">// atan(tan(1))</span>
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">f</span>.<span class="ident">tan</span>().<span class="ident">atan</span>() <span class="op">-</span> <span class="number">1.0</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.atan2' class='method'><span id='atan2.v' class='invisible'><code>fn <a href='#tymethod.atan2' class='fnname'>atan2</a>(self, other: Self) -> Self</code></span></h3><div class='docblock'><p>Computes the four quadrant arctangent of <code>self</code> (<code>y</code>) and <code>other</code> (<code>x</code>).</p>
|
||
<ul>
|
||
<li><code>x = 0</code>, <code>y = 0</code>: <code>0</code></li>
|
||
<li><code>x >= 0</code>: <code>arctan(y/x)</code> -> <code>[-pi/2, pi/2]</code></li>
|
||
<li><code>y >= 0</code>: <code>arctan(y/x) + pi</code> -> <code>(pi/2, pi]</code></li>
|
||
<li><code>y < 0</code>: <code>arctan(y/x) - pi</code> -> <code>(-pi, -pi/2)</code></li>
|
||
</ul>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">pi</span> <span class="op">=</span> <span class="ident">f64</span>::<span class="ident">consts</span>::<span class="ident">PI</span>;
|
||
<span class="comment">// All angles from horizontal right (+x)</span>
|
||
<span class="comment">// 45 deg counter-clockwise</span>
|
||
<span class="kw">let</span> <span class="ident">x1</span> <span class="op">=</span> <span class="number">3.0</span>;
|
||
<span class="kw">let</span> <span class="ident">y1</span> <span class="op">=</span> <span class="op">-</span><span class="number">3.0</span>;
|
||
|
||
<span class="comment">// 135 deg clockwise</span>
|
||
<span class="kw">let</span> <span class="ident">x2</span> <span class="op">=</span> <span class="op">-</span><span class="number">3.0</span>;
|
||
<span class="kw">let</span> <span class="ident">y2</span> <span class="op">=</span> <span class="number">3.0</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">abs_difference_1</span> <span class="op">=</span> (<span class="ident">y1</span>.<span class="ident">atan2</span>(<span class="ident">x1</span>) <span class="op">-</span> (<span class="op">-</span><span class="ident">pi</span><span class="op">/</span><span class="number">4.0</span>)).<span class="ident">abs</span>();
|
||
<span class="kw">let</span> <span class="ident">abs_difference_2</span> <span class="op">=</span> (<span class="ident">y2</span>.<span class="ident">atan2</span>(<span class="ident">x2</span>) <span class="op">-</span> <span class="number">3.0</span><span class="kw-2">*</span><span class="ident">pi</span><span class="op">/</span><span class="number">4.0</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference_1</span> <span class="op"><</span> <span class="number">1e-10</span>);
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference_2</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.sin_cos' class='method'><span id='sin_cos.v' class='invisible'><code>fn <a href='#tymethod.sin_cos' class='fnname'>sin_cos</a>(self) -> <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>Simultaneously computes the sine and cosine of the number, <code>x</code>. Returns
|
||
<code>(sin(x), cos(x))</code>.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="ident">f64</span>::<span class="ident">consts</span>::<span class="ident">PI</span><span class="op">/</span><span class="number">4.0</span>;
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">x</span>.<span class="ident">sin_cos</span>();
|
||
|
||
<span class="kw">let</span> <span class="ident">abs_difference_0</span> <span class="op">=</span> (<span class="ident">f</span>.<span class="number">0</span> <span class="op">-</span> <span class="ident">x</span>.<span class="ident">sin</span>()).<span class="ident">abs</span>();
|
||
<span class="kw">let</span> <span class="ident">abs_difference_1</span> <span class="op">=</span> (<span class="ident">f</span>.<span class="number">1</span> <span class="op">-</span> <span class="ident">x</span>.<span class="ident">cos</span>()).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference_0</span> <span class="op"><</span> <span class="number">1e-10</span>);
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference_0</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.exp_m1' class='method'><span id='exp_m1.v' class='invisible'><code>fn <a href='#tymethod.exp_m1' class='fnname'>exp_m1</a>(self) -> Self</code></span></h3><div class='docblock'><p>Returns <code>e^(self) - 1</code> in a way that is accurate even if the
|
||
number is close to zero.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">7.0</span>;
|
||
|
||
<span class="comment">// e^(ln(7)) - 1</span>
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">x</span>.<span class="ident">ln</span>().<span class="ident">exp_m1</span>() <span class="op">-</span> <span class="number">6.0</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.ln_1p' class='method'><span id='ln_1p.v' class='invisible'><code>fn <a href='#tymethod.ln_1p' class='fnname'>ln_1p</a>(self) -> Self</code></span></h3><div class='docblock'><p>Returns <code>ln(1+n)</code> (natural logarithm) more accurately than if
|
||
the operations were performed separately.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="ident">f64</span>::<span class="ident">consts</span>::<span class="ident">E</span> <span class="op">-</span> <span class="number">1.0</span>;
|
||
|
||
<span class="comment">// ln(1 + (e - 1)) == ln(e) == 1</span>
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">x</span>.<span class="ident">ln_1p</span>() <span class="op">-</span> <span class="number">1.0</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.sinh' class='method'><span id='sinh.v' class='invisible'><code>fn <a href='#tymethod.sinh' class='fnname'>sinh</a>(self) -> Self</code></span></h3><div class='docblock'><p>Hyperbolic sine function.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">e</span> <span class="op">=</span> <span class="ident">f64</span>::<span class="ident">consts</span>::<span class="ident">E</span>;
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">1.0</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">x</span>.<span class="ident">sinh</span>();
|
||
<span class="comment">// Solving sinh() at 1 gives `(e^2-1)/(2e)`</span>
|
||
<span class="kw">let</span> <span class="ident">g</span> <span class="op">=</span> (<span class="ident">e</span><span class="kw-2">*</span><span class="ident">e</span> <span class="op">-</span> <span class="number">1.0</span>)<span class="op">/</span>(<span class="number">2.0</span><span class="kw-2">*</span><span class="ident">e</span>);
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">f</span> <span class="op">-</span> <span class="ident">g</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='tymethod.cosh' class='method'><span id='cosh.v' class='invisible'><code>fn <a href='#tymethod.cosh' class='fnname'>cosh</a>(self) -> Self</code></span></h3><div class='docblock'><p>Hyperbolic cosine function.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">e</span> <span class="op">=</span> <span class="ident">f64</span>::<span class="ident">consts</span>::<span class="ident">E</span>;
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">1.0</span>;
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">x</span>.<span class="ident">cosh</span>();
|
||
<span class="comment">// Solving cosh() at 1 gives this result</span>
|
||
<span class="kw">let</span> <span class="ident">g</span> <span class="op">=</span> (<span class="ident">e</span><span class="kw-2">*</span><span class="ident">e</span> <span class="op">+</span> <span class="number">1.0</span>)<span class="op">/</span>(<span class="number">2.0</span><span class="kw-2">*</span><span class="ident">e</span>);
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">f</span> <span class="op">-</span> <span class="ident">g</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="comment">// Same result</span>
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1.0e-10</span>);</pre>
|
||
</div><h3 id='tymethod.tanh' class='method'><span id='tanh.v' class='invisible'><code>fn <a href='#tymethod.tanh' class='fnname'>tanh</a>(self) -> Self</code></span></h3><div class='docblock'><p>Hyperbolic tangent function.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">e</span> <span class="op">=</span> <span class="ident">f64</span>::<span class="ident">consts</span>::<span class="ident">E</span>;
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">1.0</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">x</span>.<span class="ident">tanh</span>();
|
||
<span class="comment">// Solving tanh() at 1 gives `(1 - e^(-2))/(1 + e^(-2))`</span>
|
||
<span class="kw">let</span> <span class="ident">g</span> <span class="op">=</span> (<span class="number">1.0</span> <span class="op">-</span> <span class="ident">e</span>.<span class="ident">powi</span>(<span class="op">-</span><span class="number">2</span>))<span class="op">/</span>(<span class="number">1.0</span> <span class="op">+</span> <span class="ident">e</span>.<span class="ident">powi</span>(<span class="op">-</span><span class="number">2</span>));
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">f</span> <span class="op">-</span> <span class="ident">g</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1.0e-10</span>);</pre>
|
||
</div><h3 id='tymethod.asinh' class='method'><span id='asinh.v' class='invisible'><code>fn <a href='#tymethod.asinh' class='fnname'>asinh</a>(self) -> Self</code></span></h3><div class='docblock'><p>Inverse hyperbolic sine function.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">1.0</span>;
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">x</span>.<span class="ident">sinh</span>().<span class="ident">asinh</span>();
|
||
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">f</span> <span class="op">-</span> <span class="ident">x</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1.0e-10</span>);</pre>
|
||
</div><h3 id='tymethod.acosh' class='method'><span id='acosh.v' class='invisible'><code>fn <a href='#tymethod.acosh' class='fnname'>acosh</a>(self) -> Self</code></span></h3><div class='docblock'><p>Inverse hyperbolic cosine function.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">1.0</span>;
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">x</span>.<span class="ident">cosh</span>().<span class="ident">acosh</span>();
|
||
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">f</span> <span class="op">-</span> <span class="ident">x</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1.0e-10</span>);</pre>
|
||
</div><h3 id='tymethod.atanh' class='method'><span id='atanh.v' class='invisible'><code>fn <a href='#tymethod.atanh' class='fnname'>atanh</a>(self) -> Self</code></span></h3><div class='docblock'><p>Inverse hyperbolic tangent function.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">e</span> <span class="op">=</span> <span class="ident">f64</span>::<span class="ident">consts</span>::<span class="ident">E</span>;
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">e</span>.<span class="ident">tanh</span>().<span class="ident">atanh</span>();
|
||
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">f</span> <span class="op">-</span> <span class="ident">e</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1.0e-10</span>);</pre>
|
||
</div><h3 id='tymethod.integer_decode' class='method'><span id='integer_decode.v' class='invisible'><code>fn <a href='#tymethod.integer_decode' class='fnname'>integer_decode</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code></span></h3><div class='docblock'><p>Returns the mantissa, base 2 exponent, and sign as integers, respectively.
|
||
The original number can be recovered by <code>sign * mantissa * 2 ^ exponent</code>.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">num</span> <span class="op">=</span> <span class="number">2.0f32</span>;
|
||
|
||
<span class="comment">// (8388608, -22, 1)</span>
|
||
<span class="kw">let</span> (<span class="ident">mantissa</span>, <span class="ident">exponent</span>, <span class="ident">sign</span>) <span class="op">=</span> <span class="ident">Float</span>::<span class="ident">integer_decode</span>(<span class="ident">num</span>);
|
||
<span class="kw">let</span> <span class="ident">sign_f</span> <span class="op">=</span> <span class="ident">sign</span> <span class="kw">as</span> <span class="ident">f32</span>;
|
||
<span class="kw">let</span> <span class="ident">mantissa_f</span> <span class="op">=</span> <span class="ident">mantissa</span> <span class="kw">as</span> <span class="ident">f32</span>;
|
||
<span class="kw">let</span> <span class="ident">exponent_f</span> <span class="op">=</span> <span class="ident">num</span>.<span class="ident">powf</span>(<span class="ident">exponent</span> <span class="kw">as</span> <span class="ident">f32</span>);
|
||
|
||
<span class="comment">// 1 * 8388608 * 2^(-22) == 2</span>
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">sign_f</span> <span class="op">*</span> <span class="ident">mantissa_f</span> <span class="op">*</span> <span class="ident">exponent_f</span> <span class="op">-</span> <span class="ident">num</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div></div>
|
||
<h2 id='provided-methods' class='small-section-header'>
|
||
Provided Methods<a href='#provided-methods' class='anchor'></a>
|
||
</h2>
|
||
<div class='methods'>
|
||
<h3 id='method.epsilon' class='method'><span id='epsilon.v' class='invisible'><code>fn <a href='#method.epsilon' class='fnname'>epsilon</a>() -> Self</code></span></h3><div class='docblock'><p>Returns epsilon, a small positive value.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">num_traits</span>::<span class="ident">Float</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">x</span>: <span class="ident">f64</span> <span class="op">=</span> <span class="ident">Float</span>::<span class="ident">epsilon</span>();
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">x</span>, <span class="ident">f64</span>::<span class="ident">EPSILON</span>);</pre>
|
||
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
|
||
<p>The default implementation will panic if <code>f32::EPSILON</code> cannot
|
||
be cast to <code>Self</code>.</p>
|
||
</div><h3 id='method.to_degrees' class='method'><span id='to_degrees.v' class='invisible'><code>fn <a href='#method.to_degrees' class='fnname'>to_degrees</a>(self) -> Self</code></span></h3><div class='docblock'><p>Converts radians to degrees.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>::<span class="ident">consts</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">angle</span> <span class="op">=</span> <span class="ident">consts</span>::<span class="ident">PI</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">angle</span>.<span class="ident">to_degrees</span>() <span class="op">-</span> <span class="number">180.0</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div><h3 id='method.to_radians' class='method'><span id='to_radians.v' class='invisible'><code>fn <a href='#method.to_radians' class='fnname'>to_radians</a>(self) -> Self</code></span></h3><div class='docblock'><p>Converts degrees to radians.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">f64</span>::<span class="ident">consts</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">angle</span> <span class="op">=</span> <span class="number">180.0_f64</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">abs_difference</span> <span class="op">=</span> (<span class="ident">angle</span>.<span class="ident">to_radians</span>() <span class="op">-</span> <span class="ident">consts</span>::<span class="ident">PI</span>).<span class="ident">abs</span>();
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">abs_difference</span> <span class="op"><</span> <span class="number">1e-10</span>);</pre>
|
||
</div></div>
|
||
<h2 id='foreign-impls' class='small-section-header'>
|
||
Implementations on Foreign Types<a href='#foreign-impls' class='anchor'></a>
|
||
</h2>
|
||
<h3 id='impl-Float' class='impl'><span class='in-band'><code>impl <a class="trait" href="../../num_traits/float/trait.Float.html" title="trait num_traits::float::Float">Float</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code><a href='#impl-Float' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/float.rs.html#1806-1878' title='goto source code'>[src]</a></span></h3>
|
||
<span class='docblock autohide'><div class='impl-items'><h4 id='method.nan' class="method"><span id='nan.v-1' class='invisible'><code>fn <a href='#method.nan' class='fnname'>nan</a>() -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#33-35' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.infinity' class="method"><span id='infinity.v-1' class='invisible'><code>fn <a href='#method.infinity' class='fnname'>infinity</a>() -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#33-35' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.neg_infinity' class="method"><span id='neg_infinity.v-1' class='invisible'><code>fn <a href='#method.neg_infinity' class='fnname'>neg_infinity</a>() -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#33-35' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.neg_zero' class="method"><span id='neg_zero.v-1' class='invisible'><code>fn <a href='#method.neg_zero' class='fnname'>neg_zero</a>() -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#33-35' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.min_value' class="method"><span id='min_value.v-1' class='invisible'><code>fn <a href='#method.min_value' class='fnname'>min_value</a>() -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#33-35' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.min_positive_value' class="method"><span id='min_positive_value.v-1' class='invisible'><code>fn <a href='#method.min_positive_value' class='fnname'>min_positive_value</a>() -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#33-35' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.epsilon-1' class="method"><span id='epsilon.v-1' class='invisible'><code>fn <a href='#method.epsilon' class='fnname'>epsilon</a>() -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#33-35' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.max_value' class="method"><span id='max_value.v-1' class='invisible'><code>fn <a href='#method.max_value' class='fnname'>max_value</a>() -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#33-35' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.abs_sub' class="method"><span id='abs_sub.v-1' class='invisible'><code>fn <a href='#method.abs_sub' class='fnname'>abs_sub</a>(self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/float.rs.html#1820-1822' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.integer_decode' class="method"><span id='integer_decode.v-1' class='invisible'><code>fn <a href='#method.integer_decode' class='fnname'>integer_decode</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/float.rs.html#1825-1827' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.is_nan' class="method"><span id='is_nan.v-1' class='invisible'><code>fn <a href='#method.is_nan' class='fnname'>is_nan</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.is_infinite' class="method"><span id='is_infinite.v-1' class='invisible'><code>fn <a href='#method.is_infinite' class='fnname'>is_infinite</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.is_finite' class="method"><span id='is_finite.v-1' class='invisible'><code>fn <a href='#method.is_finite' class='fnname'>is_finite</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.is_normal' class="method"><span id='is_normal.v-1' class='invisible'><code>fn <a href='#method.is_normal' class='fnname'>is_normal</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.classify' class="method"><span id='classify.v-1' class='invisible'><code>fn <a href='#method.classify' class='fnname'>classify</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/num/enum.FpCategory.html" title="enum core::num::FpCategory">FpCategory</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.floor' class="method"><span id='floor.v-1' class='invisible'><code>fn <a href='#method.floor' class='fnname'>floor</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.ceil' class="method"><span id='ceil.v-1' class='invisible'><code>fn <a href='#method.ceil' class='fnname'>ceil</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.round' class="method"><span id='round.v-1' class='invisible'><code>fn <a href='#method.round' class='fnname'>round</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.trunc' class="method"><span id='trunc.v-1' class='invisible'><code>fn <a href='#method.trunc' class='fnname'>trunc</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.fract' class="method"><span id='fract.v-1' class='invisible'><code>fn <a href='#method.fract' class='fnname'>fract</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.abs' class="method"><span id='abs.v-1' class='invisible'><code>fn <a href='#method.abs' class='fnname'>abs</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.signum' class="method"><span id='signum.v-1' class='invisible'><code>fn <a href='#method.signum' class='fnname'>signum</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.is_sign_positive' class="method"><span id='is_sign_positive.v-1' class='invisible'><code>fn <a href='#method.is_sign_positive' class='fnname'>is_sign_positive</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.is_sign_negative' class="method"><span id='is_sign_negative.v-1' class='invisible'><code>fn <a href='#method.is_sign_negative' class='fnname'>is_sign_negative</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.mul_add' class="method"><span id='mul_add.v-1' class='invisible'><code>fn <a href='#method.mul_add' class='fnname'>mul_add</a>(self, a: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>, b: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.recip' class="method"><span id='recip.v-1' class='invisible'><code>fn <a href='#method.recip' class='fnname'>recip</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.powi' class="method"><span id='powi.v-1' class='invisible'><code>fn <a href='#method.powi' class='fnname'>powi</a>(self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.powf' class="method"><span id='powf.v-1' class='invisible'><code>fn <a href='#method.powf' class='fnname'>powf</a>(self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.sqrt' class="method"><span id='sqrt.v-1' class='invisible'><code>fn <a href='#method.sqrt' class='fnname'>sqrt</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.exp' class="method"><span id='exp.v-1' class='invisible'><code>fn <a href='#method.exp' class='fnname'>exp</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.exp2' class="method"><span id='exp2.v-1' class='invisible'><code>fn <a href='#method.exp2' class='fnname'>exp2</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.ln' class="method"><span id='ln.v-1' class='invisible'><code>fn <a href='#method.ln' class='fnname'>ln</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.log' class="method"><span id='log.v-1' class='invisible'><code>fn <a href='#method.log' class='fnname'>log</a>(self, base: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.log2' class="method"><span id='log2.v-1' class='invisible'><code>fn <a href='#method.log2' class='fnname'>log2</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.log10' class="method"><span id='log10.v-1' class='invisible'><code>fn <a href='#method.log10' class='fnname'>log10</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.to_degrees-1' class="method"><span id='to_degrees.v-1' class='invisible'><code>fn <a href='#method.to_degrees' class='fnname'>to_degrees</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.to_radians-1' class="method"><span id='to_radians.v-1' class='invisible'><code>fn <a href='#method.to_radians' class='fnname'>to_radians</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.max' class="method"><span id='max.v-1' class='invisible'><code>fn <a href='#method.max' class='fnname'>max</a>(self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.min' class="method"><span id='min.v-1' class='invisible'><code>fn <a href='#method.min' class='fnname'>min</a>(self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.cbrt' class="method"><span id='cbrt.v-1' class='invisible'><code>fn <a href='#method.cbrt' class='fnname'>cbrt</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.hypot' class="method"><span id='hypot.v-1' class='invisible'><code>fn <a href='#method.hypot' class='fnname'>hypot</a>(self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.sin' class="method"><span id='sin.v-1' class='invisible'><code>fn <a href='#method.sin' class='fnname'>sin</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.cos' class="method"><span id='cos.v-1' class='invisible'><code>fn <a href='#method.cos' class='fnname'>cos</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.tan' class="method"><span id='tan.v-1' class='invisible'><code>fn <a href='#method.tan' class='fnname'>tan</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.asin' class="method"><span id='asin.v-1' class='invisible'><code>fn <a href='#method.asin' class='fnname'>asin</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.acos' class="method"><span id='acos.v-1' class='invisible'><code>fn <a href='#method.acos' class='fnname'>acos</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.atan' class="method"><span id='atan.v-1' class='invisible'><code>fn <a href='#method.atan' class='fnname'>atan</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.atan2' class="method"><span id='atan2.v-1' class='invisible'><code>fn <a href='#method.atan2' class='fnname'>atan2</a>(self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.sin_cos' class="method"><span id='sin_cos.v-1' class='invisible'><code>fn <a href='#method.sin_cos' class='fnname'>sin_cos</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.exp_m1' class="method"><span id='exp_m1.v-1' class='invisible'><code>fn <a href='#method.exp_m1' class='fnname'>exp_m1</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.ln_1p' class="method"><span id='ln_1p.v-1' class='invisible'><code>fn <a href='#method.ln_1p' class='fnname'>ln_1p</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.sinh' class="method"><span id='sinh.v-1' class='invisible'><code>fn <a href='#method.sinh' class='fnname'>sinh</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.cosh' class="method"><span id='cosh.v-1' class='invisible'><code>fn <a href='#method.cosh' class='fnname'>cosh</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.tanh' class="method"><span id='tanh.v-1' class='invisible'><code>fn <a href='#method.tanh' class='fnname'>tanh</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.asinh' class="method"><span id='asinh.v-1' class='invisible'><code>fn <a href='#method.asinh' class='fnname'>asinh</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.acosh' class="method"><span id='acosh.v-1' class='invisible'><code>fn <a href='#method.acosh' class='fnname'>acosh</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.atanh' class="method"><span id='atanh.v-1' class='invisible'><code>fn <a href='#method.atanh' class='fnname'>atanh</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
</div></span><h3 id='impl-Float-1' class='impl'><span class='in-band'><code>impl <a class="trait" href="../../num_traits/float/trait.Float.html" title="trait num_traits::float::Float">Float</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code><a href='#impl-Float-1' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/float.rs.html#1806-1878' title='goto source code'>[src]</a></span></h3>
|
||
<span class='docblock autohide'><div class='impl-items'><h4 id='method.nan-1' class="method"><span id='nan.v-2' class='invisible'><code>fn <a href='#method.nan' class='fnname'>nan</a>() -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#33-35' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.infinity-1' class="method"><span id='infinity.v-2' class='invisible'><code>fn <a href='#method.infinity' class='fnname'>infinity</a>() -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#33-35' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.neg_infinity-1' class="method"><span id='neg_infinity.v-2' class='invisible'><code>fn <a href='#method.neg_infinity' class='fnname'>neg_infinity</a>() -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#33-35' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.neg_zero-1' class="method"><span id='neg_zero.v-2' class='invisible'><code>fn <a href='#method.neg_zero' class='fnname'>neg_zero</a>() -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#33-35' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.min_value-1' class="method"><span id='min_value.v-2' class='invisible'><code>fn <a href='#method.min_value' class='fnname'>min_value</a>() -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#33-35' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.min_positive_value-1' class="method"><span id='min_positive_value.v-2' class='invisible'><code>fn <a href='#method.min_positive_value' class='fnname'>min_positive_value</a>() -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#33-35' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.epsilon-2' class="method"><span id='epsilon.v-2' class='invisible'><code>fn <a href='#method.epsilon' class='fnname'>epsilon</a>() -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#33-35' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.max_value-1' class="method"><span id='max_value.v-2' class='invisible'><code>fn <a href='#method.max_value' class='fnname'>max_value</a>() -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#33-35' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.abs_sub-1' class="method"><span id='abs_sub.v-2' class='invisible'><code>fn <a href='#method.abs_sub' class='fnname'>abs_sub</a>(self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/float.rs.html#1820-1822' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.integer_decode-1' class="method"><span id='integer_decode.v-2' class='invisible'><code>fn <a href='#method.integer_decode' class='fnname'>integer_decode</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/float.rs.html#1825-1827' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.is_nan-1' class="method"><span id='is_nan.v-2' class='invisible'><code>fn <a href='#method.is_nan' class='fnname'>is_nan</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.is_infinite-1' class="method"><span id='is_infinite.v-2' class='invisible'><code>fn <a href='#method.is_infinite' class='fnname'>is_infinite</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.is_finite-1' class="method"><span id='is_finite.v-2' class='invisible'><code>fn <a href='#method.is_finite' class='fnname'>is_finite</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.is_normal-1' class="method"><span id='is_normal.v-2' class='invisible'><code>fn <a href='#method.is_normal' class='fnname'>is_normal</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.classify-1' class="method"><span id='classify.v-2' class='invisible'><code>fn <a href='#method.classify' class='fnname'>classify</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/num/enum.FpCategory.html" title="enum core::num::FpCategory">FpCategory</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.floor-1' class="method"><span id='floor.v-2' class='invisible'><code>fn <a href='#method.floor' class='fnname'>floor</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.ceil-1' class="method"><span id='ceil.v-2' class='invisible'><code>fn <a href='#method.ceil' class='fnname'>ceil</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.round-1' class="method"><span id='round.v-2' class='invisible'><code>fn <a href='#method.round' class='fnname'>round</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.trunc-1' class="method"><span id='trunc.v-2' class='invisible'><code>fn <a href='#method.trunc' class='fnname'>trunc</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.fract-1' class="method"><span id='fract.v-2' class='invisible'><code>fn <a href='#method.fract' class='fnname'>fract</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.abs-1' class="method"><span id='abs.v-2' class='invisible'><code>fn <a href='#method.abs' class='fnname'>abs</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.signum-1' class="method"><span id='signum.v-2' class='invisible'><code>fn <a href='#method.signum' class='fnname'>signum</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.is_sign_positive-1' class="method"><span id='is_sign_positive.v-2' class='invisible'><code>fn <a href='#method.is_sign_positive' class='fnname'>is_sign_positive</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.is_sign_negative-1' class="method"><span id='is_sign_negative.v-2' class='invisible'><code>fn <a href='#method.is_sign_negative' class='fnname'>is_sign_negative</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.mul_add-1' class="method"><span id='mul_add.v-2' class='invisible'><code>fn <a href='#method.mul_add' class='fnname'>mul_add</a>(self, a: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>, b: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.recip-1' class="method"><span id='recip.v-2' class='invisible'><code>fn <a href='#method.recip' class='fnname'>recip</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.powi-1' class="method"><span id='powi.v-2' class='invisible'><code>fn <a href='#method.powi' class='fnname'>powi</a>(self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.powf-1' class="method"><span id='powf.v-2' class='invisible'><code>fn <a href='#method.powf' class='fnname'>powf</a>(self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.sqrt-1' class="method"><span id='sqrt.v-2' class='invisible'><code>fn <a href='#method.sqrt' class='fnname'>sqrt</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.exp-1' class="method"><span id='exp.v-2' class='invisible'><code>fn <a href='#method.exp' class='fnname'>exp</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.exp2-1' class="method"><span id='exp2.v-2' class='invisible'><code>fn <a href='#method.exp2' class='fnname'>exp2</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.ln-1' class="method"><span id='ln.v-2' class='invisible'><code>fn <a href='#method.ln' class='fnname'>ln</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.log-1' class="method"><span id='log.v-2' class='invisible'><code>fn <a href='#method.log' class='fnname'>log</a>(self, base: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.log2-1' class="method"><span id='log2.v-2' class='invisible'><code>fn <a href='#method.log2' class='fnname'>log2</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.log10-1' class="method"><span id='log10.v-2' class='invisible'><code>fn <a href='#method.log10' class='fnname'>log10</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.to_degrees-2' class="method"><span id='to_degrees.v-2' class='invisible'><code>fn <a href='#method.to_degrees' class='fnname'>to_degrees</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.to_radians-2' class="method"><span id='to_radians.v-2' class='invisible'><code>fn <a href='#method.to_radians' class='fnname'>to_radians</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.max-1' class="method"><span id='max.v-2' class='invisible'><code>fn <a href='#method.max' class='fnname'>max</a>(self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.min-1' class="method"><span id='min.v-2' class='invisible'><code>fn <a href='#method.min' class='fnname'>min</a>(self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.cbrt-1' class="method"><span id='cbrt.v-2' class='invisible'><code>fn <a href='#method.cbrt' class='fnname'>cbrt</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.hypot-1' class="method"><span id='hypot.v-2' class='invisible'><code>fn <a href='#method.hypot' class='fnname'>hypot</a>(self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.sin-1' class="method"><span id='sin.v-2' class='invisible'><code>fn <a href='#method.sin' class='fnname'>sin</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.cos-1' class="method"><span id='cos.v-2' class='invisible'><code>fn <a href='#method.cos' class='fnname'>cos</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.tan-1' class="method"><span id='tan.v-2' class='invisible'><code>fn <a href='#method.tan' class='fnname'>tan</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.asin-1' class="method"><span id='asin.v-2' class='invisible'><code>fn <a href='#method.asin' class='fnname'>asin</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.acos-1' class="method"><span id='acos.v-2' class='invisible'><code>fn <a href='#method.acos' class='fnname'>acos</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.atan-1' class="method"><span id='atan.v-2' class='invisible'><code>fn <a href='#method.atan' class='fnname'>atan</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.atan2-1' class="method"><span id='atan2.v-2' class='invisible'><code>fn <a href='#method.atan2' class='fnname'>atan2</a>(self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.sin_cos-1' class="method"><span id='sin_cos.v-2' class='invisible'><code>fn <a href='#method.sin_cos' class='fnname'>sin_cos</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.exp_m1-1' class="method"><span id='exp_m1.v-2' class='invisible'><code>fn <a href='#method.exp_m1' class='fnname'>exp_m1</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.ln_1p-1' class="method"><span id='ln_1p.v-2' class='invisible'><code>fn <a href='#method.ln_1p' class='fnname'>ln_1p</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.sinh-1' class="method"><span id='sinh.v-2' class='invisible'><code>fn <a href='#method.sinh' class='fnname'>sinh</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.cosh-1' class="method"><span id='cosh.v-2' class='invisible'><code>fn <a href='#method.cosh' class='fnname'>cosh</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.tanh-1' class="method"><span id='tanh.v-2' class='invisible'><code>fn <a href='#method.tanh' class='fnname'>tanh</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.asinh-1' class="method"><span id='asinh.v-2' class='invisible'><code>fn <a href='#method.asinh' class='fnname'>asinh</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.acosh-1' class="method"><span id='acosh.v-2' class='invisible'><code>fn <a href='#method.acosh' class='fnname'>acosh</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
<h4 id='method.atanh-1' class="method"><span id='atanh.v-2' class='invisible'><code>fn <a href='#method.atanh' class='fnname'>atanh</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/num_traits/macros.rs.html#9-11' title='goto source code'>[src]</a></span></h4>
|
||
</div></span>
|
||
<h2 id='implementors' class='small-section-header'>
|
||
Implementors<a href='#implementors' class='anchor'></a>
|
||
</h2>
|
||
<ul class='item-list' id='implementors-list'>
|
||
</ul><script type="text/javascript" async
|
||
src="../../implementors/num_traits/float/trait.Float.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><kbd>?</kbd></dt>
|
||
<dd>Show this help dialog</dd>
|
||
<dt><kbd>S</kbd></dt>
|
||
<dd>Focus the search field</dd>
|
||
<dt><kbd>↑</kbd></dt>
|
||
<dd>Move up in search results</dd>
|
||
<dt><kbd>↓</kbd></dt>
|
||
<dd>Move down in search results</dd>
|
||
<dt><kbd>↹</kbd></dt>
|
||
<dd>Switch tab</dd>
|
||
<dt><kbd>⏎</kbd></dt>
|
||
<dd>Go to active search result</dd>
|
||
<dt><kbd>+</kbd></dt>
|
||
<dd>Expand all sections</dd>
|
||
<dt><kbd>-</kbd></dt>
|
||
<dd>Collapse 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_traits";
|
||
</script>
|
||
<script src="../../main.js"></script>
|
||
<script defer src="../../search-index.js"></script>
|
||
</body>
|
||
</html> |