date_component 0.4.8

the missed date_component with chrono. calculate date interval with chrono.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
<!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="Generic trait for floating point numbers that works with `no_std`."><title>FloatCore in num_traits::float - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Bold-a2c9cd1067f8b328.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c4dbdcde0fbd8430.css" id="mainThemeStyle"><link rel="stylesheet" id="themeStyle" href="../../static.files/light-db279b6232be9c13.css"><link rel="stylesheet" disabled href="../../static.files/dark-cf923f49f397b216.css"><link rel="stylesheet" disabled href="../../static.files/ayu-be46fdc453a55015.css"><script src="../../static.files/storage-3891ce972e3a2bf8.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-98a684e84ae5b08b.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-13285aec31fa243e.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-16x16-8b506e7a72182f1c.png"><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="logo-container" href="../../num_traits/index.html"><img class="rust-logo" src="../../static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></a><h2></h2></nav><nav class="sidebar"><a class="logo-container" href="../../num_traits/index.html"><img class="rust-logo" src="../../static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></a><h2 class="location"><a href="#">FloatCore</a></h2><div class="sidebar-elems"><section><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.classify">classify</a></li><li><a href="#tymethod.epsilon">epsilon</a></li><li><a href="#tymethod.infinity">infinity</a></li><li><a href="#tymethod.integer_decode">integer_decode</a></li><li><a href="#tymethod.max_value">max_value</a></li><li><a href="#tymethod.min_positive_value">min_positive_value</a></li><li><a href="#tymethod.min_value">min_value</a></li><li><a href="#tymethod.nan">nan</a></li><li><a href="#tymethod.neg_infinity">neg_infinity</a></li><li><a href="#tymethod.neg_zero">neg_zero</a></li><li><a href="#tymethod.to_degrees">to_degrees</a></li><li><a href="#tymethod.to_radians">to_radians</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.abs">abs</a></li><li><a href="#method.ceil">ceil</a></li><li><a href="#method.floor">floor</a></li><li><a href="#method.fract">fract</a></li><li><a href="#method.is_finite">is_finite</a></li><li><a href="#method.is_infinite">is_infinite</a></li><li><a href="#method.is_nan">is_nan</a></li><li><a href="#method.is_normal">is_normal</a></li><li><a href="#method.is_sign_negative">is_sign_negative</a></li><li><a href="#method.is_sign_positive">is_sign_positive</a></li><li><a href="#method.is_subnormal">is_subnormal</a></li><li><a href="#method.max">max</a></li><li><a href="#method.min">min</a></li><li><a href="#method.powi">powi</a></li><li><a href="#method.recip">recip</a></li><li><a href="#method.round">round</a></li><li><a href="#method.signum">signum</a></li><li><a href="#method.trunc">trunc</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-FloatCore-for-f32">f32</a></li><li><a href="#impl-FloatCore-for-f64">f64</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><h2><a href="index.html">In num_traits::float</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Trait <a href="../index.html">num_traits</a>::<wbr><a href="index.html">float</a>::<wbr><a class="trait" href="#">FloatCore</a><button id="copy-path" title="Copy item path to clipboard"><img src="../../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../../src/num_traits/float.rs.html#12-768">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><pre class="rust item-decl"><code>pub trait FloatCore: <a class="trait" href="../trait.Num.html" title="trait num_traits::Num">Num</a> + <a class="trait" href="../cast/trait.NumCast.html" title="trait num_traits::cast::NumCast">NumCast</a> + <a class="trait" href="https://doc.rust-lang.org/1.69.0/core/ops/arith/trait.Neg.html" title="trait core::ops::arith::Neg">Neg</a>&lt;Output = Self&gt; + <a class="trait" href="https://doc.rust-lang.org/1.69.0/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a> + <a class="trait" href="https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> {
<details class="toggle type-contents-toggle"><summary class="hideme"><span>Show 30 methods</span></summary>    // Required methods
    fn <a href="#tymethod.infinity" class="fn">infinity</a>() -&gt; Self;
<span class="item-spacer"></span>    fn <a href="#tymethod.neg_infinity" class="fn">neg_infinity</a>() -&gt; Self;
<span class="item-spacer"></span>    fn <a href="#tymethod.nan" class="fn">nan</a>() -&gt; Self;
<span class="item-spacer"></span>    fn <a href="#tymethod.neg_zero" class="fn">neg_zero</a>() -&gt; Self;
<span class="item-spacer"></span>    fn <a href="#tymethod.min_value" class="fn">min_value</a>() -&gt; Self;
<span class="item-spacer"></span>    fn <a href="#tymethod.min_positive_value" class="fn">min_positive_value</a>() -&gt; Self;
<span class="item-spacer"></span>    fn <a href="#tymethod.epsilon" class="fn">epsilon</a>() -&gt; Self;
<span class="item-spacer"></span>    fn <a href="#tymethod.max_value" class="fn">max_value</a>() -&gt; Self;
<span class="item-spacer"></span>    fn <a href="#tymethod.classify" class="fn">classify</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.69.0/core/num/enum.FpCategory.html" title="enum core::num::FpCategory">FpCategory</a>;
<span class="item-spacer"></span>    fn <a href="#tymethod.to_degrees" class="fn">to_degrees</a>(self) -&gt; Self;
<span class="item-spacer"></span>    fn <a href="#tymethod.to_radians" class="fn">to_radians</a>(self) -&gt; Self;
<span class="item-spacer"></span>    fn <a href="#tymethod.integer_decode" class="fn">integer_decode</a>(self) -&gt; (<a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.u64.html">u64</a>, <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.i16.html">i16</a>, <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.i8.html">i8</a>);

    // Provided methods
    fn <a href="#method.is_nan" class="fn">is_nan</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a> { ... }
<span class="item-spacer"></span>    fn <a href="#method.is_infinite" class="fn">is_infinite</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a> { ... }
<span class="item-spacer"></span>    fn <a href="#method.is_finite" class="fn">is_finite</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a> { ... }
<span class="item-spacer"></span>    fn <a href="#method.is_normal" class="fn">is_normal</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a> { ... }
<span class="item-spacer"></span>    fn <a href="#method.is_subnormal" class="fn">is_subnormal</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a> { ... }
<span class="item-spacer"></span>    fn <a href="#method.floor" class="fn">floor</a>(self) -&gt; Self { ... }
<span class="item-spacer"></span>    fn <a href="#method.ceil" class="fn">ceil</a>(self) -&gt; Self { ... }
<span class="item-spacer"></span>    fn <a href="#method.round" class="fn">round</a>(self) -&gt; Self { ... }
<span class="item-spacer"></span>    fn <a href="#method.trunc" class="fn">trunc</a>(self) -&gt; Self { ... }
<span class="item-spacer"></span>    fn <a href="#method.fract" class="fn">fract</a>(self) -&gt; Self { ... }
<span class="item-spacer"></span>    fn <a href="#method.abs" class="fn">abs</a>(self) -&gt; Self { ... }
<span class="item-spacer"></span>    fn <a href="#method.signum" class="fn">signum</a>(self) -&gt; Self { ... }
<span class="item-spacer"></span>    fn <a href="#method.is_sign_positive" class="fn">is_sign_positive</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a> { ... }
<span class="item-spacer"></span>    fn <a href="#method.is_sign_negative" class="fn">is_sign_negative</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a> { ... }
<span class="item-spacer"></span>    fn <a href="#method.min" class="fn">min</a>(self, other: Self) -&gt; Self { ... }
<span class="item-spacer"></span>    fn <a href="#method.max" class="fn">max</a>(self, other: Self) -&gt; Self { ... }
<span class="item-spacer"></span>    fn <a href="#method.recip" class="fn">recip</a>(self) -&gt; Self { ... }
<span class="item-spacer"></span>    fn <a href="#method.powi" class="fn">powi</a>(self, exp: <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.i32.html">i32</a>) -&gt; Self { ... }
</details>}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Generic trait for floating point numbers that works with <code>no_std</code>.</p>
<p>This trait implements a subset of the <code>Float</code> trait.</p>
</div></details><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.infinity" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#28">source</a><h4 class="code-header">fn <a href="#tymethod.infinity" class="fn">infinity</a>() -&gt; Self</h4></section></summary><div class="docblock"><p>Returns positive infinity.</p>
<h5 id="examples"><a href="#examples">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T) {
    <span class="macro">assert!</span>(T::infinity() == x);
}

check(f32::INFINITY);
check(f64::INFINITY);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.neg_infinity" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#45">source</a><h4 class="code-header">fn <a href="#tymethod.neg_infinity" class="fn">neg_infinity</a>() -&gt; Self</h4></section></summary><div class="docblock"><p>Returns negative infinity.</p>
<h5 id="examples-1"><a href="#examples-1">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T) {
    <span class="macro">assert!</span>(T::neg_infinity() == x);
}

check(f32::NEG_INFINITY);
check(f64::NEG_INFINITY);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.nan" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#62">source</a><h4 class="code-header">fn <a href="#tymethod.nan" class="fn">nan</a>() -&gt; Self</h4></section></summary><div class="docblock"><p>Returns NaN.</p>
<h5 id="examples-2"><a href="#examples-2">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;

<span class="kw">fn </span>check&lt;T: FloatCore&gt;() {
    <span class="kw">let </span>n = T::nan();
    <span class="macro">assert!</span>(n != n);
}

check::&lt;f32&gt;();
check::&lt;f64&gt;();</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.neg_zero" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#81">source</a><h4 class="code-header">fn <a href="#tymethod.neg_zero" class="fn">neg_zero</a>() -&gt; Self</h4></section></summary><div class="docblock"><p>Returns <code>-0.0</code>.</p>
<h5 id="examples-3"><a href="#examples-3">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(n: T) {
    <span class="kw">let </span>z = T::neg_zero();
    <span class="macro">assert!</span>(z.is_zero());
    <span class="macro">assert!</span>(T::one() / z == n);
}

check(f32::NEG_INFINITY);
check(f64::NEG_INFINITY);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.min_value" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#98">source</a><h4 class="code-header">fn <a href="#tymethod.min_value" class="fn">min_value</a>() -&gt; Self</h4></section></summary><div class="docblock"><p>Returns the smallest finite value that this type can represent.</p>
<h5 id="examples-4"><a href="#examples-4">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T) {
    <span class="macro">assert!</span>(T::min_value() == x);
}

check(f32::MIN);
check(f64::MIN);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.min_positive_value" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#115">source</a><h4 class="code-header">fn <a href="#tymethod.min_positive_value" class="fn">min_positive_value</a>() -&gt; Self</h4></section></summary><div class="docblock"><p>Returns the smallest positive, normalized value that this type can represent.</p>
<h5 id="examples-5"><a href="#examples-5">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T) {
    <span class="macro">assert!</span>(T::min_positive_value() == x);
}

check(f32::MIN_POSITIVE);
check(f64::MIN_POSITIVE);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.epsilon" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#132">source</a><h4 class="code-header">fn <a href="#tymethod.epsilon" class="fn">epsilon</a>() -&gt; Self</h4></section></summary><div class="docblock"><p>Returns epsilon, a small positive value.</p>
<h5 id="examples-6"><a href="#examples-6">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T) {
    <span class="macro">assert!</span>(T::epsilon() == x);
}

check(f32::EPSILON);
check(f64::EPSILON);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.max_value" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#149">source</a><h4 class="code-header">fn <a href="#tymethod.max_value" class="fn">max_value</a>() -&gt; Self</h4></section></summary><div class="docblock"><p>Returns the largest finite value that this type can represent.</p>
<h5 id="examples-7"><a href="#examples-7">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T) {
    <span class="macro">assert!</span>(T::max_value() == x);
}

check(f32::MAX);
check(f64::MAX);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.classify" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#292">source</a><h4 class="code-header">fn <a href="#tymethod.classify" class="fn">classify</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.69.0/core/num/enum.FpCategory.html" title="enum core::num::FpCategory">FpCategory</a></h4></section></summary><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>
<h5 id="examples-8"><a href="#examples-8">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};
<span class="kw">use </span>std::num::FpCategory;

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T, c: FpCategory) {
    <span class="macro">assert!</span>(x.classify() == c);
}

check(f32::INFINITY, FpCategory::Infinite);
check(f32::MAX, FpCategory::Normal);
check(f64::NAN, FpCategory::Nan);
check(f64::MIN_POSITIVE, FpCategory::Normal);
check(f64::MIN_POSITIVE / <span class="number">2.0</span>, FpCategory::Subnormal);
check(<span class="number">0.0f64</span>, FpCategory::Zero);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.to_degrees" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#725">source</a><h4 class="code-header">fn <a href="#tymethod.to_degrees" class="fn">to_degrees</a>(self) -&gt; Self</h4></section></summary><div class="docblock"><p>Converts to degrees, assuming the number is in radians.</p>
<h5 id="examples-9"><a href="#examples-9">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(rad: T, deg: T) {
    <span class="macro">assert!</span>(rad.to_degrees() == deg);
}

check(<span class="number">0.0f32</span>, <span class="number">0.0</span>);
check(f32::consts::PI, <span class="number">180.0</span>);
check(f64::consts::FRAC_PI_4, <span class="number">45.0</span>);
check(f64::INFINITY, f64::INFINITY);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.to_radians" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#744">source</a><h4 class="code-header">fn <a href="#tymethod.to_radians" class="fn">to_radians</a>(self) -&gt; Self</h4></section></summary><div class="docblock"><p>Converts to radians, assuming the number is in degrees.</p>
<h5 id="examples-10"><a href="#examples-10">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(deg: T, rad: T) {
    <span class="macro">assert!</span>(deg.to_radians() == rad);
}

check(<span class="number">0.0f32</span>, <span class="number">0.0</span>);
check(<span class="number">180.0</span>, f32::consts::PI);
check(<span class="number">45.0</span>, f64::consts::FRAC_PI_4);
check(f64::INFINITY, f64::INFINITY);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.integer_decode" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#767">source</a><h4 class="code-header">fn <a href="#tymethod.integer_decode" class="fn">integer_decode</a>(self) -&gt; (<a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.u64.html">u64</a>, <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.i16.html">i16</a>, <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.i8.html">i8</a>)</h4></section></summary><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>
<h5 id="examples-11"><a href="#examples-11">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T, m: u64, e: i16, s:i8) {
    <span class="kw">let </span>(mantissa, exponent, sign) = x.integer_decode();
    <span class="macro">assert_eq!</span>(mantissa, m);
    <span class="macro">assert_eq!</span>(exponent, e);
    <span class="macro">assert_eq!</span>(sign, s);
}

check(<span class="number">2.0f32</span>, <span class="number">1 </span>&lt;&lt; <span class="number">23</span>, -<span class="number">22</span>, <span class="number">1</span>);
check(-<span class="number">2.0f32</span>, <span class="number">1 </span>&lt;&lt; <span class="number">23</span>, -<span class="number">22</span>, -<span class="number">1</span>);
check(f32::INFINITY, <span class="number">1 </span>&lt;&lt; <span class="number">23</span>, <span class="number">105</span>, <span class="number">1</span>);
check(f64::NEG_INFINITY, <span class="number">1 </span>&lt;&lt; <span class="number">52</span>, <span class="number">972</span>, -<span class="number">1</span>);</code></pre></div>
</div></details></div><h2 id="provided-methods" class="small-section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.is_nan" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#170-172">source</a><h4 class="code-header">fn <a href="#method.is_nan" class="fn">is_nan</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the number is NaN.</p>
<h5 id="examples-12"><a href="#examples-12">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T, p: bool) {
    <span class="macro">assert!</span>(x.is_nan() == p);
}

check(f32::NAN, <span class="bool-val">true</span>);
check(f32::INFINITY, <span class="bool-val">false</span>);
check(f64::NAN, <span class="bool-val">true</span>);
check(<span class="number">0.0f64</span>, <span class="bool-val">false</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_infinite" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#194-196">source</a><h4 class="code-header">fn <a href="#method.is_infinite" class="fn">is_infinite</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the number is infinite.</p>
<h5 id="examples-13"><a href="#examples-13">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T, p: bool) {
    <span class="macro">assert!</span>(x.is_infinite() == p);
}

check(f32::INFINITY, <span class="bool-val">true</span>);
check(f32::NEG_INFINITY, <span class="bool-val">true</span>);
check(f32::NAN, <span class="bool-val">false</span>);
check(f64::INFINITY, <span class="bool-val">true</span>);
check(f64::NEG_INFINITY, <span class="bool-val">true</span>);
check(<span class="number">0.0f64</span>, <span class="bool-val">false</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_finite" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#217-219">source</a><h4 class="code-header">fn <a href="#method.is_finite" class="fn">is_finite</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the number is neither infinite or NaN.</p>
<h5 id="examples-14"><a href="#examples-14">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T, p: bool) {
    <span class="macro">assert!</span>(x.is_finite() == p);
}

check(f32::INFINITY, <span class="bool-val">false</span>);
check(f32::MAX, <span class="bool-val">true</span>);
check(f64::NEG_INFINITY, <span class="bool-val">false</span>);
check(f64::MIN_POSITIVE, <span class="bool-val">true</span>);
check(f64::NAN, <span class="bool-val">false</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_normal" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#240-242">source</a><h4 class="code-header">fn <a href="#method.is_normal" class="fn">is_normal</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the number is neither zero, infinite, subnormal or NaN.</p>
<h5 id="examples-15"><a href="#examples-15">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T, p: bool) {
    <span class="macro">assert!</span>(x.is_normal() == p);
}

check(f32::INFINITY, <span class="bool-val">false</span>);
check(f32::MAX, <span class="bool-val">true</span>);
check(f64::NEG_INFINITY, <span class="bool-val">false</span>);
check(f64::MIN_POSITIVE, <span class="bool-val">true</span>);
check(<span class="number">0.0f64</span>, <span class="bool-val">false</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_subnormal" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#266-268">source</a><h4 class="code-header">fn <a href="#method.is_subnormal" class="fn">is_subnormal</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the number is <a href="https://en.wikipedia.org/wiki/Subnormal_number">subnormal</a>.</p>

<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::f64;

<span class="kw">let </span>min = f64::MIN_POSITIVE; <span class="comment">// 2.2250738585072014e-308_f64
</span><span class="kw">let </span>max = f64::MAX;
<span class="kw">let </span>lower_than_min = <span class="number">1.0e-308_f64</span>;
<span class="kw">let </span>zero = <span class="number">0.0_f64</span>;

<span class="macro">assert!</span>(!min.is_subnormal());
<span class="macro">assert!</span>(!max.is_subnormal());

<span class="macro">assert!</span>(!zero.is_subnormal());
<span class="macro">assert!</span>(!f64::NAN.is_subnormal());
<span class="macro">assert!</span>(!f64::INFINITY.is_subnormal());
<span class="comment">// Values between `0` and `min` are Subnormal.
</span><span class="macro">assert!</span>(lower_than_min.is_subnormal());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.floor" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#317-326">source</a><h4 class="code-header">fn <a href="#method.floor" class="fn">floor</a>(self) -&gt; Self</h4></section></summary><div class="docblock"><p>Returns the largest integer less than or equal to a number.</p>
<h5 id="examples-16"><a href="#examples-16">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T, y: T) {
    <span class="macro">assert!</span>(x.floor() == y);
}

check(f32::INFINITY, f32::INFINITY);
check(<span class="number">0.9f32</span>, <span class="number">0.0</span>);
check(<span class="number">1.0f32</span>, <span class="number">1.0</span>);
check(<span class="number">1.1f32</span>, <span class="number">1.0</span>);
check(-<span class="number">0.0f64</span>, <span class="number">0.0</span>);
check(-<span class="number">0.9f64</span>, -<span class="number">1.0</span>);
check(-<span class="number">1.0f64</span>, -<span class="number">1.0</span>);
check(-<span class="number">1.1f64</span>, -<span class="number">2.0</span>);
check(f64::MIN, f64::MIN);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.ceil" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#351-360">source</a><h4 class="code-header">fn <a href="#method.ceil" class="fn">ceil</a>(self) -&gt; Self</h4></section></summary><div class="docblock"><p>Returns the smallest integer greater than or equal to a number.</p>
<h5 id="examples-17"><a href="#examples-17">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T, y: T) {
    <span class="macro">assert!</span>(x.ceil() == y);
}

check(f32::INFINITY, f32::INFINITY);
check(<span class="number">0.9f32</span>, <span class="number">1.0</span>);
check(<span class="number">1.0f32</span>, <span class="number">1.0</span>);
check(<span class="number">1.1f32</span>, <span class="number">2.0</span>);
check(-<span class="number">0.0f64</span>, <span class="number">0.0</span>);
check(-<span class="number">0.9f64</span>, -<span class="number">0.0</span>);
check(-<span class="number">1.0f64</span>, -<span class="number">1.0</span>);
check(-<span class="number">1.1f64</span>, -<span class="number">1.0</span>);
check(f64::MIN, f64::MIN);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.round" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#384-401">source</a><h4 class="code-header">fn <a href="#method.round" class="fn">round</a>(self) -&gt; Self</h4></section></summary><div class="docblock"><p>Returns the nearest integer to a number. Round half-way cases away from <code>0.0</code>.</p>
<h5 id="examples-18"><a href="#examples-18">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T, y: T) {
    <span class="macro">assert!</span>(x.round() == y);
}

check(f32::INFINITY, f32::INFINITY);
check(<span class="number">0.4f32</span>, <span class="number">0.0</span>);
check(<span class="number">0.5f32</span>, <span class="number">1.0</span>);
check(<span class="number">0.6f32</span>, <span class="number">1.0</span>);
check(-<span class="number">0.4f64</span>, <span class="number">0.0</span>);
check(-<span class="number">0.5f64</span>, -<span class="number">1.0</span>);
check(-<span class="number">0.6f64</span>, -<span class="number">1.0</span>);
check(f64::MIN, f64::MIN);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.trunc" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#426-433">source</a><h4 class="code-header">fn <a href="#method.trunc" class="fn">trunc</a>(self) -&gt; Self</h4></section></summary><div class="docblock"><p>Return the integer part of a number.</p>
<h5 id="examples-19"><a href="#examples-19">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T, y: T) {
    <span class="macro">assert!</span>(x.trunc() == y);
}

check(f32::INFINITY, f32::INFINITY);
check(<span class="number">0.9f32</span>, <span class="number">0.0</span>);
check(<span class="number">1.0f32</span>, <span class="number">1.0</span>);
check(<span class="number">1.1f32</span>, <span class="number">1.0</span>);
check(-<span class="number">0.0f64</span>, <span class="number">0.0</span>);
check(-<span class="number">0.9f64</span>, -<span class="number">0.0</span>);
check(-<span class="number">1.0f64</span>, -<span class="number">1.0</span>);
check(-<span class="number">1.1f64</span>, -<span class="number">1.0</span>);
check(f64::MIN, f64::MIN);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.fract" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#458-464">source</a><h4 class="code-header">fn <a href="#method.fract" class="fn">fract</a>(self) -&gt; Self</h4></section></summary><div class="docblock"><p>Returns the fractional part of a number.</p>
<h5 id="examples-20"><a href="#examples-20">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T, y: T) {
    <span class="macro">assert!</span>(x.fract() == y);
}

check(f32::MAX, <span class="number">0.0</span>);
check(<span class="number">0.75f32</span>, <span class="number">0.75</span>);
check(<span class="number">1.0f32</span>, <span class="number">0.0</span>);
check(<span class="number">1.25f32</span>, <span class="number">0.25</span>);
check(-<span class="number">0.0f64</span>, <span class="number">0.0</span>);
check(-<span class="number">0.75f64</span>, -<span class="number">0.75</span>);
check(-<span class="number">1.0f64</span>, <span class="number">0.0</span>);
check(-<span class="number">1.25f64</span>, -<span class="number">0.25</span>);
check(f64::MIN, <span class="number">0.0</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.abs" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#487-495">source</a><h4 class="code-header">fn <a href="#method.abs" class="fn">abs</a>(self) -&gt; Self</h4></section></summary><div class="docblock"><p>Computes the absolute value of <code>self</code>. Returns <code>FloatCore::nan()</code> if the
number is <code>FloatCore::nan()</code>.</p>
<h5 id="examples-21"><a href="#examples-21">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T, y: T) {
    <span class="macro">assert!</span>(x.abs() == y);
}

check(f32::INFINITY, f32::INFINITY);
check(<span class="number">1.0f32</span>, <span class="number">1.0</span>);
check(<span class="number">0.0f64</span>, <span class="number">0.0</span>);
check(-<span class="number">0.0f64</span>, <span class="number">0.0</span>);
check(-<span class="number">1.0f64</span>, <span class="number">1.0</span>);
check(f64::MIN, f64::MAX);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.signum" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#521-529">source</a><h4 class="code-header">fn <a href="#method.signum" class="fn">signum</a>(self) -&gt; Self</h4></section></summary><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>FloatCore::infinity()</code></li>
<li><code>-1.0</code> if the number is negative, <code>-0.0</code> or <code>FloatCore::neg_infinity()</code></li>
<li><code>FloatCore::nan()</code> if the number is <code>FloatCore::nan()</code></li>
</ul>
<h5 id="examples-22"><a href="#examples-22">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T, y: T) {
    <span class="macro">assert!</span>(x.signum() == y);
}

check(f32::INFINITY, <span class="number">1.0</span>);
check(<span class="number">3.0f32</span>, <span class="number">1.0</span>);
check(<span class="number">0.0f32</span>, <span class="number">1.0</span>);
check(-<span class="number">0.0f64</span>, -<span class="number">1.0</span>);
check(-<span class="number">3.0f64</span>, -<span class="number">1.0</span>);
check(f64::MIN, -<span class="number">1.0</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_sign_positive" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#554-556">source</a><h4 class="code-header">fn <a href="#method.is_sign_positive" class="fn">is_sign_positive</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if <code>self</code> is positive, including <code>+0.0</code> and
<code>FloatCore::infinity()</code>, and <code>FloatCore::nan()</code>.</p>
<h5 id="examples-23"><a href="#examples-23">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T, p: bool) {
    <span class="macro">assert!</span>(x.is_sign_positive() == p);
}

check(f32::INFINITY, <span class="bool-val">true</span>);
check(f32::MAX, <span class="bool-val">true</span>);
check(<span class="number">0.0f32</span>, <span class="bool-val">true</span>);
check(-<span class="number">0.0f64</span>, <span class="bool-val">false</span>);
check(f64::NEG_INFINITY, <span class="bool-val">false</span>);
check(f64::MIN_POSITIVE, <span class="bool-val">true</span>);
check(f64::NAN, <span class="bool-val">true</span>);
check(-f64::NAN, <span class="bool-val">false</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_sign_negative" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#581-584">source</a><h4 class="code-header">fn <a href="#method.is_sign_negative" class="fn">is_sign_negative</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if <code>self</code> is negative, including <code>-0.0</code> and
<code>FloatCore::neg_infinity()</code>, and <code>-FloatCore::nan()</code>.</p>
<h5 id="examples-24"><a href="#examples-24">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T, p: bool) {
    <span class="macro">assert!</span>(x.is_sign_negative() == p);
}

check(f32::INFINITY, <span class="bool-val">false</span>);
check(f32::MAX, <span class="bool-val">false</span>);
check(<span class="number">0.0f32</span>, <span class="bool-val">false</span>);
check(-<span class="number">0.0f64</span>, <span class="bool-val">true</span>);
check(f64::NEG_INFINITY, <span class="bool-val">true</span>);
check(f64::MIN_POSITIVE, <span class="bool-val">false</span>);
check(f64::NAN, <span class="bool-val">false</span>);
check(-f64::NAN, <span class="bool-val">true</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.min" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#606-618">source</a><h4 class="code-header">fn <a href="#method.min" class="fn">min</a>(self, other: Self) -&gt; Self</h4></section></summary><div class="docblock"><p>Returns the minimum of the two numbers.</p>
<p>If one of the arguments is NaN, then the other argument is returned.</p>
<h5 id="examples-25"><a href="#examples-25">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T, y: T, min: T) {
    <span class="macro">assert!</span>(x.min(y) == min);
}

check(<span class="number">1.0f32</span>, <span class="number">2.0</span>, <span class="number">1.0</span>);
check(f32::NAN, <span class="number">2.0</span>, <span class="number">2.0</span>);
check(<span class="number">1.0f64</span>, -<span class="number">2.0</span>, -<span class="number">2.0</span>);
check(<span class="number">1.0f64</span>, f64::NAN, <span class="number">1.0</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.max" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#640-652">source</a><h4 class="code-header">fn <a href="#method.max" class="fn">max</a>(self, other: Self) -&gt; Self</h4></section></summary><div class="docblock"><p>Returns the maximum of the two numbers.</p>
<p>If one of the arguments is NaN, then the other argument is returned.</p>
<h5 id="examples-26"><a href="#examples-26">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T, y: T, max: T) {
    <span class="macro">assert!</span>(x.max(y) == max);
}

check(<span class="number">1.0f32</span>, <span class="number">2.0</span>, <span class="number">2.0</span>);
check(<span class="number">1.0f32</span>, f32::NAN, <span class="number">1.0</span>);
check(-<span class="number">1.0f64</span>, <span class="number">2.0</span>, <span class="number">2.0</span>);
check(-<span class="number">1.0f64</span>, f64::NAN, -<span class="number">1.0</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.recip" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#673-675">source</a><h4 class="code-header">fn <a href="#method.recip" class="fn">recip</a>(self) -&gt; Self</h4></section></summary><div class="docblock"><p>Returns the reciprocal (multiplicative inverse) of the number.</p>
<h5 id="examples-27"><a href="#examples-27">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;
<span class="kw">use </span>std::{f32, f64};

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T, y: T) {
    <span class="macro">assert!</span>(x.recip() == y);
    <span class="macro">assert!</span>(y.recip() == x);
}

check(f32::INFINITY, <span class="number">0.0</span>);
check(<span class="number">2.0f32</span>, <span class="number">0.5</span>);
check(-<span class="number">0.25f64</span>, -<span class="number">4.0</span>);
check(-<span class="number">0.0f64</span>, f64::NEG_INFINITY);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.powi" class="method"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#697-706">source</a><h4 class="code-header">fn <a href="#method.powi" class="fn">powi</a>(self, exp: <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.i32.html">i32</a>) -&gt; Self</h4></section></summary><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>
<h5 id="examples-28"><a href="#examples-28">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>num_traits::float::FloatCore;

<span class="kw">fn </span>check&lt;T: FloatCore&gt;(x: T, exp: i32, powi: T) {
    <span class="macro">assert!</span>(x.powi(exp) == powi);
}

check(<span class="number">9.0f32</span>, <span class="number">2</span>, <span class="number">81.0</span>);
check(<span class="number">1.0f32</span>, -<span class="number">2</span>, <span class="number">1.0</span>);
check(<span class="number">10.0f64</span>, <span class="number">20</span>, <span class="number">1e20</span>);
check(<span class="number">4.0f64</span>, -<span class="number">2</span>, <span class="number">0.0625</span>);
check(-<span class="number">1.0f64</span>, std::i32::MIN, <span class="number">1.0</span>);</code></pre></div>
</div></details></div><h2 id="foreign-impls" class="small-section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-FloatCore-for-f64" class="impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#835-898">source</a><a href="#impl-FloatCore-for-f64" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FloatCore.html" title="trait num_traits::float::FloatCore">FloatCore</a> for <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.f64.html">f64</a></h3></section></summary><div class="impl-items"><section id="method.infinity" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#836-845">source</a><a href="#method.infinity" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.infinity" class="fn">infinity</a>() -&gt; Self</h4></section><section id="method.neg_infinity" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#836-845">source</a><a href="#method.neg_infinity" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.neg_infinity" class="fn">neg_infinity</a>() -&gt; Self</h4></section><section id="method.nan" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#836-845">source</a><a href="#method.nan" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.nan" class="fn">nan</a>() -&gt; Self</h4></section><section id="method.neg_zero" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#836-845">source</a><a href="#method.neg_zero" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.neg_zero" class="fn">neg_zero</a>() -&gt; Self</h4></section><section id="method.min_value" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#836-845">source</a><a href="#method.min_value" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.min_value" class="fn">min_value</a>() -&gt; Self</h4></section><section id="method.min_positive_value" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#836-845">source</a><a href="#method.min_positive_value" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.min_positive_value" class="fn">min_positive_value</a>() -&gt; Self</h4></section><section id="method.epsilon" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#836-845">source</a><a href="#method.epsilon" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.epsilon" class="fn">epsilon</a>() -&gt; Self</h4></section><section id="method.max_value" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#836-845">source</a><a href="#method.max_value" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.max_value" class="fn">max_value</a>() -&gt; Self</h4></section><section id="method.integer_decode" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#848-850">source</a><a href="#method.integer_decode" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.integer_decode" class="fn">integer_decode</a>(self) -&gt; (<a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.u64.html">u64</a>, <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.i16.html">i16</a>, <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.i8.html">i8</a>)</h4></section><section id="method.is_nan-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#852-865">source</a><a href="#method.is_nan-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.is_nan" class="fn">is_nan</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section><section id="method.is_infinite-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#852-865">source</a><a href="#method.is_infinite-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.is_infinite" class="fn">is_infinite</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section><section id="method.is_finite-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#852-865">source</a><a href="#method.is_finite-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.is_finite" class="fn">is_finite</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section><section id="method.is_normal-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#852-865">source</a><a href="#method.is_normal-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.is_normal" class="fn">is_normal</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section><section id="method.classify" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#852-865">source</a><a href="#method.classify" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.classify" class="fn">classify</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.69.0/core/num/enum.FpCategory.html" title="enum core::num::FpCategory">FpCategory</a></h4></section><section id="method.is_sign_positive-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#852-865">source</a><a href="#method.is_sign_positive-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.is_sign_positive" class="fn">is_sign_positive</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section><section id="method.is_sign_negative-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#852-865">source</a><a href="#method.is_sign_negative-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.is_sign_negative" class="fn">is_sign_negative</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section><section id="method.min-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#852-865">source</a><a href="#method.min-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.min" class="fn">min</a>(self, other: Self) -&gt; Self</h4></section><section id="method.max-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#852-865">source</a><a href="#method.max-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.max" class="fn">max</a>(self, other: Self) -&gt; Self</h4></section><section id="method.recip-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#852-865">source</a><a href="#method.recip-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.recip" class="fn">recip</a>(self) -&gt; Self</h4></section><section id="method.to_degrees" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#852-865">source</a><a href="#method.to_degrees" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.to_degrees" class="fn">to_degrees</a>(self) -&gt; Self</h4></section><section id="method.to_radians" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#852-865">source</a><a href="#method.to_radians" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.to_radians" class="fn">to_radians</a>(self) -&gt; Self</h4></section><section id="method.is_subnormal-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#868-870">source</a><a href="#method.is_subnormal-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.is_subnormal" class="fn">is_subnormal</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-FloatCore-for-f32" class="impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#770-833">source</a><a href="#impl-FloatCore-for-f32" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FloatCore.html" title="trait num_traits::float::FloatCore">FloatCore</a> for <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.f32.html">f32</a></h3></section></summary><div class="impl-items"><section id="method.infinity-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#771-780">source</a><a href="#method.infinity-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.infinity" class="fn">infinity</a>() -&gt; Self</h4></section><section id="method.neg_infinity-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#771-780">source</a><a href="#method.neg_infinity-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.neg_infinity" class="fn">neg_infinity</a>() -&gt; Self</h4></section><section id="method.nan-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#771-780">source</a><a href="#method.nan-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.nan" class="fn">nan</a>() -&gt; Self</h4></section><section id="method.neg_zero-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#771-780">source</a><a href="#method.neg_zero-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.neg_zero" class="fn">neg_zero</a>() -&gt; Self</h4></section><section id="method.min_value-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#771-780">source</a><a href="#method.min_value-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.min_value" class="fn">min_value</a>() -&gt; Self</h4></section><section id="method.min_positive_value-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#771-780">source</a><a href="#method.min_positive_value-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.min_positive_value" class="fn">min_positive_value</a>() -&gt; Self</h4></section><section id="method.epsilon-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#771-780">source</a><a href="#method.epsilon-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.epsilon" class="fn">epsilon</a>() -&gt; Self</h4></section><section id="method.max_value-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#771-780">source</a><a href="#method.max_value-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.max_value" class="fn">max_value</a>() -&gt; Self</h4></section><section id="method.integer_decode-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#783-785">source</a><a href="#method.integer_decode-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.integer_decode" class="fn">integer_decode</a>(self) -&gt; (<a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.u64.html">u64</a>, <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.i16.html">i16</a>, <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.i8.html">i8</a>)</h4></section><section id="method.is_nan-2" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#787-800">source</a><a href="#method.is_nan-2" class="anchor">§</a><h4 class="code-header">fn <a href="#method.is_nan" class="fn">is_nan</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section><section id="method.is_infinite-2" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#787-800">source</a><a href="#method.is_infinite-2" class="anchor">§</a><h4 class="code-header">fn <a href="#method.is_infinite" class="fn">is_infinite</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section><section id="method.is_finite-2" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#787-800">source</a><a href="#method.is_finite-2" class="anchor">§</a><h4 class="code-header">fn <a href="#method.is_finite" class="fn">is_finite</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section><section id="method.is_normal-2" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#787-800">source</a><a href="#method.is_normal-2" class="anchor">§</a><h4 class="code-header">fn <a href="#method.is_normal" class="fn">is_normal</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section><section id="method.classify-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#787-800">source</a><a href="#method.classify-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.classify" class="fn">classify</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.69.0/core/num/enum.FpCategory.html" title="enum core::num::FpCategory">FpCategory</a></h4></section><section id="method.is_sign_positive-2" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#787-800">source</a><a href="#method.is_sign_positive-2" class="anchor">§</a><h4 class="code-header">fn <a href="#method.is_sign_positive" class="fn">is_sign_positive</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section><section id="method.is_sign_negative-2" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#787-800">source</a><a href="#method.is_sign_negative-2" class="anchor">§</a><h4 class="code-header">fn <a href="#method.is_sign_negative" class="fn">is_sign_negative</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section><section id="method.min-2" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#787-800">source</a><a href="#method.min-2" class="anchor">§</a><h4 class="code-header">fn <a href="#method.min" class="fn">min</a>(self, other: Self) -&gt; Self</h4></section><section id="method.max-2" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#787-800">source</a><a href="#method.max-2" class="anchor">§</a><h4 class="code-header">fn <a href="#method.max" class="fn">max</a>(self, other: Self) -&gt; Self</h4></section><section id="method.recip-2" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#787-800">source</a><a href="#method.recip-2" class="anchor">§</a><h4 class="code-header">fn <a href="#method.recip" class="fn">recip</a>(self) -&gt; Self</h4></section><section id="method.to_degrees-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#787-800">source</a><a href="#method.to_degrees-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.to_degrees" class="fn">to_degrees</a>(self) -&gt; Self</h4></section><section id="method.to_radians-1" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#787-800">source</a><a href="#method.to_radians-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.to_radians" class="fn">to_radians</a>(self) -&gt; Self</h4></section><section id="method.is_subnormal-2" class="method trait-impl"><a class="srclink rightside" href="../../src/num_traits/float.rs.html#803-805">source</a><a href="#method.is_subnormal-2" class="anchor">§</a><h4 class="code-header">fn <a href="#method.is_subnormal" class="fn">is_subnormal</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.69.0/core/primitive.bool.html">bool</a></h4></section></div></details><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"></div><script src="../../implementors/num_traits/float/trait.FloatCore.js" data-ignore-extern-crates="core" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="num_traits" data-themes="" data-resource-suffix="" data-rustdoc-version="1.69.0 (84c898d65 2023-04-16) (built from a source tarball)" data-search-js="search-8a59a8356673ec1f.js" data-settings-js="settings-f0c5c39777a9a2f6.js" data-settings-css="settings-0bcba95ff279c1db.css" ></div></body></html>