Skip to main content

std/num/
f64.rs

1//! Constants for the `f64` double-precision floating point type.
2//!
3//! *[See also the `f64` primitive type](primitive@f64).*
4//!
5//! Mathematically significant numbers are provided in the `consts` sub-module.
6//!
7//! For the constants defined directly in this module
8//! (as distinct from those defined in the `consts` sub-module),
9//! new code should instead use the associated constants
10//! defined directly on the `f64` type.
11
12#![stable(feature = "rust1", since = "1.0.0")]
13#![allow(missing_docs)]
14
15#[stable(feature = "rust1", since = "1.0.0")]
16#[allow(deprecated, clippy::legacy_numeric_constants)]
17pub use core::f64::{
18    DIGITS, EPSILON, INFINITY, MANTISSA_DIGITS, MAX, MAX_10_EXP, MAX_EXP, MIN, MIN_10_EXP, MIN_EXP,
19    MIN_POSITIVE, NAN, NEG_INFINITY, RADIX, consts,
20};
21
22#[cfg(not(test))]
23use crate::intrinsics;
24#[cfg(not(test))]
25use crate::sys::cmath;
26
27#[cfg(not(test))]
28impl f64 {
29    /// Returns the largest integer that is less than or equal to `self`.
30    ///
31    /// This function always returns the precise result.
32    ///
33    /// # Examples
34    ///
35    /// ```
36    /// let f = 3.7_f64;
37    /// let g = 3.0_f64;
38    /// let h = -3.7_f64;
39    ///
40    /// assert_eq!(f.floor(), 3.0);
41    /// assert_eq!(g.floor(), 3.0);
42    /// assert_eq!(h.floor(), -4.0);
43    /// ```
44    #[rustc_allow_incoherent_impl]
45    #[must_use = "method returns a new number and does not mutate the original value"]
46    #[stable(feature = "rust1", since = "1.0.0")]
47    #[rustc_const_stable(feature = "const_float_round_methods", since = "1.90.0")]
48    #[inline]
49    pub const fn floor(self) -> f64 {
50        core::f64::math::floor(self)
51    }
52
53    /// Returns the smallest integer that is greater than or equal to `self`.
54    ///
55    /// This function always returns the precise result.
56    ///
57    /// # Examples
58    ///
59    /// ```
60    /// let f = 3.01_f64;
61    /// let g = 4.0_f64;
62    /// let h = -3.01_f64;
63    ///
64    /// assert_eq!(f.ceil(), 4.0);
65    /// assert_eq!(g.ceil(), 4.0);
66    /// assert_eq!(h.ceil(), -3.0);
67    /// ```
68    #[doc(alias = "ceiling")]
69    #[rustc_allow_incoherent_impl]
70    #[must_use = "method returns a new number and does not mutate the original value"]
71    #[stable(feature = "rust1", since = "1.0.0")]
72    #[rustc_const_stable(feature = "const_float_round_methods", since = "1.90.0")]
73    #[inline]
74    pub const fn ceil(self) -> f64 {
75        core::f64::math::ceil(self)
76    }
77
78    /// Returns the nearest integer to `self`. If a value is half-way between two
79    /// integers, round away from `0.0`.
80    ///
81    /// This function always returns the precise result.
82    ///
83    /// On most hardware platforms, [`round_ties_even`](Self::round_ties_even) may execute faster
84    /// than `round`. If both rounding methods fit the use case, consider using `round_ties_even`.
85    /// Note that the two methods apply different rounding rules to values exactly halfway between
86    /// two integers.
87    ///
88    /// # Examples
89    ///
90    /// ```
91    /// let f = 3.3_f64;
92    /// let g = -3.3_f64;
93    /// let h = -3.7_f64;
94    /// let i = 3.5_f64;
95    /// let j = 4.5_f64;
96    ///
97    /// assert_eq!(f.round(), 3.0);
98    /// assert_eq!(g.round(), -3.0);
99    /// assert_eq!(h.round(), -4.0);
100    /// assert_eq!(i.round(), 4.0);
101    /// assert_eq!(j.round(), 5.0);
102    /// ```
103    #[rustc_allow_incoherent_impl]
104    #[must_use = "method returns a new number and does not mutate the original value"]
105    #[stable(feature = "rust1", since = "1.0.0")]
106    #[rustc_const_stable(feature = "const_float_round_methods", since = "1.90.0")]
107    #[inline]
108    pub const fn round(self) -> f64 {
109        core::f64::math::round(self)
110    }
111
112    /// Returns the nearest integer to a number. Rounds half-way cases to the number
113    /// with an even least significant digit.
114    ///
115    /// This function always returns the precise result.
116    ///
117    /// # Examples
118    ///
119    /// ```
120    /// let f = 3.3_f64;
121    /// let g = -3.3_f64;
122    /// let h = 3.5_f64;
123    /// let i = 4.5_f64;
124    ///
125    /// assert_eq!(f.round_ties_even(), 3.0);
126    /// assert_eq!(g.round_ties_even(), -3.0);
127    /// assert_eq!(h.round_ties_even(), 4.0);
128    /// assert_eq!(i.round_ties_even(), 4.0);
129    /// ```
130    #[rustc_allow_incoherent_impl]
131    #[must_use = "method returns a new number and does not mutate the original value"]
132    #[stable(feature = "round_ties_even", since = "1.77.0")]
133    #[rustc_const_stable(feature = "const_float_round_methods", since = "1.90.0")]
134    #[inline]
135    pub const fn round_ties_even(self) -> f64 {
136        core::f64::math::round_ties_even(self)
137    }
138
139    /// Returns the integer part of `self`.
140    /// This means that non-integer numbers are always truncated towards zero.
141    ///
142    /// This function always returns the precise result.
143    ///
144    /// # Examples
145    ///
146    /// ```
147    /// let f = 3.7_f64;
148    /// let g = 3.0_f64;
149    /// let h = -3.7_f64;
150    ///
151    /// assert_eq!(f.trunc(), 3.0);
152    /// assert_eq!(g.trunc(), 3.0);
153    /// assert_eq!(h.trunc(), -3.0);
154    /// ```
155    #[doc(alias = "truncate")]
156    #[rustc_allow_incoherent_impl]
157    #[must_use = "method returns a new number and does not mutate the original value"]
158    #[stable(feature = "rust1", since = "1.0.0")]
159    #[rustc_const_stable(feature = "const_float_round_methods", since = "1.90.0")]
160    #[inline]
161    pub const fn trunc(self) -> f64 {
162        core::f64::math::trunc(self)
163    }
164
165    /// Returns the fractional part of `self`.
166    ///
167    /// This function always returns the precise result.
168    ///
169    /// # Examples
170    ///
171    /// ```
172    /// let x = 3.6_f64;
173    /// let y = -3.6_f64;
174    /// let abs_difference_x = (x.fract() - 0.6).abs();
175    /// let abs_difference_y = (y.fract() - (-0.6)).abs();
176    ///
177    /// assert!(abs_difference_x < 1e-10);
178    /// assert!(abs_difference_y < 1e-10);
179    /// ```
180    #[rustc_allow_incoherent_impl]
181    #[must_use = "method returns a new number and does not mutate the original value"]
182    #[stable(feature = "rust1", since = "1.0.0")]
183    #[rustc_const_stable(feature = "const_float_round_methods", since = "1.90.0")]
184    #[inline]
185    pub const fn fract(self) -> f64 {
186        core::f64::math::fract(self)
187    }
188
189    /// Fused multiply-add. Computes `(self * a) + b` with only one rounding
190    /// error, yielding a more accurate result than an unfused multiply-add.
191    ///
192    /// Using `mul_add` *may* be more performant than an unfused multiply-add if
193    /// the target architecture has a dedicated `fma` CPU instruction. However,
194    /// this is not always true, and will be heavily dependant on designing
195    /// algorithms with specific target hardware in mind.
196    ///
197    /// # Precision
198    ///
199    /// The result of this operation is guaranteed to be the rounded
200    /// infinite-precision result. It is specified by IEEE 754 as
201    /// `fusedMultiplyAdd` and guaranteed not to change.
202    ///
203    /// # Examples
204    ///
205    /// ```
206    /// let m = 10.0_f64;
207    /// let x = 4.0_f64;
208    /// let b = 60.0_f64;
209    ///
210    /// assert_eq!(m.mul_add(x, b), 100.0);
211    /// assert_eq!(m * x + b, 100.0);
212    ///
213    /// let one_plus_eps = 1.0_f64 + f64::EPSILON;
214    /// let one_minus_eps = 1.0_f64 - f64::EPSILON;
215    /// let minus_one = -1.0_f64;
216    ///
217    /// // The exact result (1 + eps) * (1 - eps) = 1 - eps * eps.
218    /// assert_eq!(one_plus_eps.mul_add(one_minus_eps, minus_one), -f64::EPSILON * f64::EPSILON);
219    /// // Different rounding with the non-fused multiply and add.
220    /// assert_eq!(one_plus_eps * one_minus_eps + minus_one, 0.0);
221    /// ```
222    #[rustc_allow_incoherent_impl]
223    #[doc(alias = "fma", alias = "fusedMultiplyAdd")]
224    #[must_use = "method returns a new number and does not mutate the original value"]
225    #[stable(feature = "rust1", since = "1.0.0")]
226    #[inline]
227    #[rustc_const_stable(feature = "const_mul_add", since = "1.94.0")]
228    pub const fn mul_add(self, a: f64, b: f64) -> f64 {
229        core::f64::math::mul_add(self, a, b)
230    }
231
232    /// Calculates Euclidean division, the matching method for `rem_euclid`.
233    ///
234    /// This computes the integer `n` such that
235    /// `self = n * rhs + self.rem_euclid(rhs)`.
236    /// In other words, the result is `self / rhs` rounded to the integer `n`
237    /// such that `self >= n * rhs`.
238    ///
239    /// # Precision
240    ///
241    /// The result of this operation is guaranteed to be the rounded
242    /// infinite-precision result.
243    ///
244    /// # Examples
245    ///
246    /// ```
247    /// let a: f64 = 7.0;
248    /// let b = 4.0;
249    /// assert_eq!(a.div_euclid(b), 1.0); // 7.0 > 4.0 * 1.0
250    /// assert_eq!((-a).div_euclid(b), -2.0); // -7.0 >= 4.0 * -2.0
251    /// assert_eq!(a.div_euclid(-b), -1.0); // 7.0 >= -4.0 * -1.0
252    /// assert_eq!((-a).div_euclid(-b), 2.0); // -7.0 >= -4.0 * 2.0
253    /// ```
254    #[rustc_allow_incoherent_impl]
255    #[must_use = "method returns a new number and does not mutate the original value"]
256    #[inline]
257    #[stable(feature = "euclidean_division", since = "1.38.0")]
258    pub fn div_euclid(self, rhs: f64) -> f64 {
259        core::f64::math::div_euclid(self, rhs)
260    }
261
262    /// Calculates the least nonnegative remainder of `self` when divided by
263    /// `rhs`.
264    ///
265    /// In particular, the return value `r` satisfies `0.0 <= r < rhs.abs()` in
266    /// most cases. However, due to a floating point round-off error it can
267    /// result in `r == rhs.abs()`, violating the mathematical definition, if
268    /// `self` is much smaller than `rhs.abs()` in magnitude and `self < 0.0`.
269    /// This result is not an element of the function's codomain, but it is the
270    /// closest floating point number in the real numbers and thus fulfills the
271    /// property `self == self.div_euclid(rhs) * rhs + self.rem_euclid(rhs)`
272    /// approximately.
273    ///
274    /// # Precision
275    ///
276    /// The result of this operation is guaranteed to be the rounded
277    /// infinite-precision result.
278    ///
279    /// # Examples
280    ///
281    /// ```
282    /// let a: f64 = 7.0;
283    /// let b = 4.0;
284    /// assert_eq!(a.rem_euclid(b), 3.0);
285    /// assert_eq!((-a).rem_euclid(b), 1.0);
286    /// assert_eq!(a.rem_euclid(-b), 3.0);
287    /// assert_eq!((-a).rem_euclid(-b), 1.0);
288    /// // limitation due to round-off error
289    /// assert!((-f64::EPSILON).rem_euclid(3.0) != 0.0);
290    /// ```
291    #[doc(alias = "modulo", alias = "mod")]
292    #[rustc_allow_incoherent_impl]
293    #[must_use = "method returns a new number and does not mutate the original value"]
294    #[inline]
295    #[stable(feature = "euclidean_division", since = "1.38.0")]
296    pub fn rem_euclid(self, rhs: f64) -> f64 {
297        core::f64::math::rem_euclid(self, rhs)
298    }
299
300    /// Raises a number to an integer power.
301    ///
302    /// Using this function is generally faster than using `powf`.
303    /// It might have a different sequence of rounding operations than `powf`,
304    /// so the results are not guaranteed to agree.
305    ///
306    /// Note that this function is special in that it can return non-NaN results for NaN inputs. For
307    /// example, `f64::powi(f64::NAN, 0)` returns `1.0`. However, if an input is a *signaling*
308    /// NaN, then the result is non-deterministically either a NaN or the result that the
309    /// corresponding quiet NaN would produce.
310    ///
311    /// # Unspecified precision
312    ///
313    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
314    /// can even differ within the same execution from one invocation to the next.
315    ///
316    /// # Examples
317    ///
318    /// ```
319    /// let x = 2.0_f64;
320    /// let abs_difference = (x.powi(2) - (x * x)).abs();
321    /// assert!(abs_difference <= 1e-14);
322    ///
323    /// assert_eq!(f64::powi(f64::NAN, 0), 1.0);
324    /// assert_eq!(f64::powi(0.0, 0), 1.0);
325    /// ```
326    #[rustc_allow_incoherent_impl]
327    #[must_use = "method returns a new number and does not mutate the original value"]
328    #[stable(feature = "rust1", since = "1.0.0")]
329    #[inline]
330    pub fn powi(self, n: i32) -> f64 {
331        core::f64::math::powi(self, n)
332    }
333
334    /// Raises a number to a floating point power.
335    ///
336    /// Note that this function is special in that it can return non-NaN results for NaN inputs. For
337    /// example, `f64::powf(f64::NAN, 0.0)` returns `1.0`. However, if an input is a *signaling*
338    /// NaN, then the result is non-deterministically either a NaN or the result that the
339    /// corresponding quiet NaN would produce.
340    ///
341    /// # Unspecified precision
342    ///
343    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
344    /// can even differ within the same execution from one invocation to the next.
345    ///
346    /// # Examples
347    ///
348    /// ```
349    /// let x = 2.0_f64;
350    /// let abs_difference = (x.powf(2.0) - (x * x)).abs();
351    /// assert!(abs_difference <= 1e-14);
352    ///
353    /// assert_eq!(f64::powf(1.0, f64::NAN), 1.0);
354    /// assert_eq!(f64::powf(f64::NAN, 0.0), 1.0);
355    /// assert_eq!(f64::powf(0.0, 0.0), 1.0);
356    /// ```
357    #[rustc_allow_incoherent_impl]
358    #[must_use = "method returns a new number and does not mutate the original value"]
359    #[stable(feature = "rust1", since = "1.0.0")]
360    #[inline]
361    pub fn powf(self, n: f64) -> f64 {
362        intrinsics::powf64(self, n)
363    }
364
365    /// Returns the square root of a number.
366    ///
367    /// Returns NaN if `self` is a negative number other than `-0.0`.
368    ///
369    /// # Precision
370    ///
371    /// The result of this operation is guaranteed to be the rounded
372    /// infinite-precision result. It is specified by IEEE 754 as `squareRoot`
373    /// and guaranteed not to change.
374    ///
375    /// # Examples
376    ///
377    /// ```
378    /// let positive = 4.0_f64;
379    /// let negative = -4.0_f64;
380    /// let negative_zero = -0.0_f64;
381    ///
382    /// assert_eq!(positive.sqrt(), 2.0);
383    /// assert!(negative.sqrt().is_nan());
384    /// assert!(negative_zero.sqrt() == negative_zero);
385    /// ```
386    #[doc(alias = "squareRoot")]
387    #[rustc_allow_incoherent_impl]
388    #[must_use = "method returns a new number and does not mutate the original value"]
389    #[stable(feature = "rust1", since = "1.0.0")]
390    #[inline]
391    pub fn sqrt(self) -> f64 {
392        core::f64::math::sqrt(self)
393    }
394
395    /// Returns `e^(self)`, (the exponential function).
396    ///
397    /// # Unspecified precision
398    ///
399    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
400    /// can even differ within the same execution from one invocation to the next.
401    ///
402    /// # Examples
403    ///
404    /// ```
405    /// let one = 1.0_f64;
406    /// // e^1
407    /// let e = one.exp();
408    ///
409    /// // ln(e) - 1 == 0
410    /// let abs_difference = (e.ln() - 1.0).abs();
411    ///
412    /// assert!(abs_difference < 1e-10);
413    /// ```
414    #[rustc_allow_incoherent_impl]
415    #[must_use = "method returns a new number and does not mutate the original value"]
416    #[stable(feature = "rust1", since = "1.0.0")]
417    #[inline]
418    pub fn exp(self) -> f64 {
419        intrinsics::exp(self)
420    }
421
422    /// Returns `2^(self)`.
423    ///
424    /// # Unspecified precision
425    ///
426    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
427    /// can even differ within the same execution from one invocation to the next.
428    ///
429    /// # Examples
430    ///
431    /// ```
432    /// let f = 2.0_f64;
433    ///
434    /// // 2^2 - 4 == 0
435    /// let abs_difference = (f.exp2() - 4.0).abs();
436    ///
437    /// assert!(abs_difference < 1e-10);
438    /// ```
439    #[rustc_allow_incoherent_impl]
440    #[must_use = "method returns a new number and does not mutate the original value"]
441    #[stable(feature = "rust1", since = "1.0.0")]
442    #[inline]
443    pub fn exp2(self) -> f64 {
444        intrinsics::exp2(self)
445    }
446
447    /// Returns the natural logarithm of the number.
448    ///
449    /// This returns NaN when the number is negative, and negative infinity when number is zero.
450    ///
451    /// # Unspecified precision
452    ///
453    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
454    /// can even differ within the same execution from one invocation to the next.
455    ///
456    /// # Examples
457    ///
458    /// ```
459    /// let one = 1.0_f64;
460    /// // e^1
461    /// let e = one.exp();
462    ///
463    /// // ln(e) - 1 == 0
464    /// let abs_difference = (e.ln() - 1.0).abs();
465    ///
466    /// assert!(abs_difference < 1e-10);
467    /// ```
468    ///
469    /// Non-positive values:
470    /// ```
471    /// assert_eq!(0_f64.ln(), f64::NEG_INFINITY);
472    /// assert!((-42_f64).ln().is_nan());
473    /// ```
474    #[rustc_allow_incoherent_impl]
475    #[must_use = "method returns a new number and does not mutate the original value"]
476    #[stable(feature = "rust1", since = "1.0.0")]
477    #[inline]
478    pub fn ln(self) -> f64 {
479        intrinsics::log(self)
480    }
481
482    /// Returns the logarithm of the number with respect to an arbitrary base.
483    ///
484    /// This returns NaN when the number is negative, and negative infinity when number is zero.
485    ///
486    /// The result might not be correctly rounded owing to implementation details;
487    /// `self.log2()` can produce more accurate results for base 2, and
488    /// `self.log10()` can produce more accurate results for base 10.
489    ///
490    /// # Unspecified precision
491    ///
492    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
493    /// can even differ within the same execution from one invocation to the next.
494    ///
495    /// # Examples
496    ///
497    /// ```
498    /// let twenty_five = 25.0_f64;
499    ///
500    /// // log5(25) - 2 == 0
501    /// let abs_difference = (twenty_five.log(5.0) - 2.0).abs();
502    ///
503    /// assert!(abs_difference < 1e-10);
504    /// ```
505    ///
506    /// Non-positive values:
507    /// ```
508    /// assert_eq!(0_f64.log(10.0), f64::NEG_INFINITY);
509    /// assert!((-42_f64).log(10.0).is_nan());
510    /// ```
511    #[rustc_allow_incoherent_impl]
512    #[must_use = "method returns a new number and does not mutate the original value"]
513    #[stable(feature = "rust1", since = "1.0.0")]
514    #[inline]
515    pub fn log(self, base: f64) -> f64 {
516        self.ln() / base.ln()
517    }
518
519    /// Returns the base 2 logarithm of the number.
520    ///
521    /// This returns NaN when the number is negative, and negative infinity when number is zero.
522    ///
523    /// # Unspecified precision
524    ///
525    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
526    /// can even differ within the same execution from one invocation to the next.
527    ///
528    /// # Examples
529    ///
530    /// ```
531    /// let four = 4.0_f64;
532    ///
533    /// // log2(4) - 2 == 0
534    /// let abs_difference = (four.log2() - 2.0).abs();
535    ///
536    /// assert!(abs_difference < 1e-10);
537    /// ```
538    ///
539    /// Non-positive values:
540    /// ```
541    /// assert_eq!(0_f64.log2(), f64::NEG_INFINITY);
542    /// assert!((-42_f64).log2().is_nan());
543    /// ```
544    #[rustc_allow_incoherent_impl]
545    #[must_use = "method returns a new number and does not mutate the original value"]
546    #[stable(feature = "rust1", since = "1.0.0")]
547    #[inline]
548    pub fn log2(self) -> f64 {
549        intrinsics::log2(self)
550    }
551
552    /// Returns the base 10 logarithm of the number.
553    ///
554    /// This returns NaN when the number is negative, and negative infinity when number is zero.
555    ///
556    /// # Unspecified precision
557    ///
558    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
559    /// can even differ within the same execution from one invocation to the next.
560    ///
561    /// # Examples
562    ///
563    /// ```
564    /// let hundred = 100.0_f64;
565    ///
566    /// // log10(100) - 2 == 0
567    /// let abs_difference = (hundred.log10() - 2.0).abs();
568    ///
569    /// assert!(abs_difference < 1e-10);
570    /// ```
571    ///
572    /// Non-positive values:
573    /// ```
574    /// assert_eq!(0_f64.log10(), f64::NEG_INFINITY);
575    /// assert!((-42_f64).log10().is_nan());
576    /// ```
577    #[rustc_allow_incoherent_impl]
578    #[must_use = "method returns a new number and does not mutate the original value"]
579    #[stable(feature = "rust1", since = "1.0.0")]
580    #[inline]
581    pub fn log10(self) -> f64 {
582        intrinsics::log10(self)
583    }
584
585    /// The positive difference of two numbers.
586    ///
587    /// * If `self <= other`: `0.0`
588    /// * Else: `self - other`
589    ///
590    /// # Unspecified precision
591    ///
592    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
593    /// can even differ within the same execution from one invocation to the next.
594    /// This function currently corresponds to the `fdim` from libc on Unix and
595    /// Windows. Note that this might change in the future.
596    ///
597    /// # Examples
598    ///
599    /// ```
600    /// let x = 3.0_f64;
601    /// let y = -3.0_f64;
602    ///
603    /// let abs_difference_x = (x.abs_sub(1.0) - 2.0).abs();
604    /// let abs_difference_y = (y.abs_sub(1.0) - 0.0).abs();
605    ///
606    /// assert!(abs_difference_x < 1e-10);
607    /// assert!(abs_difference_y < 1e-10);
608    /// ```
609    #[rustc_allow_incoherent_impl]
610    #[must_use = "method returns a new number and does not mutate the original value"]
611    #[stable(feature = "rust1", since = "1.0.0")]
612    #[inline]
613    #[deprecated(
614        since = "1.10.0",
615        note = "you probably meant `(self - other).abs()`: \
616                this operation is `(self - other).max(0.0)` \
617                except that `abs_sub` also propagates NaNs (also \
618                known as `fdim` in C). If you truly need the positive \
619                difference, consider using that expression or the C function \
620                `fdim`, depending on how you wish to handle NaN (please consider \
621                filing an issue describing your use-case too)."
622    )]
623    pub fn abs_sub(self, other: f64) -> f64 {
624        #[allow(deprecated)]
625        core::f64::math::abs_sub(self, other)
626    }
627
628    /// Returns the cube root of a number.
629    ///
630    /// # Unspecified precision
631    ///
632    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
633    /// can even differ within the same execution from one invocation to the next.
634    /// This function currently corresponds to the `cbrt` from libc on Unix and
635    /// Windows. Note that this might change in the future.
636    ///
637    /// # Examples
638    ///
639    /// ```
640    /// let x = 8.0_f64;
641    ///
642    /// // x^(1/3) - 2 == 0
643    /// let abs_difference = (x.cbrt() - 2.0).abs();
644    ///
645    /// assert!(abs_difference < 1e-10);
646    /// ```
647    #[rustc_allow_incoherent_impl]
648    #[must_use = "method returns a new number and does not mutate the original value"]
649    #[stable(feature = "rust1", since = "1.0.0")]
650    #[inline]
651    pub fn cbrt(self) -> f64 {
652        core::f64::math::cbrt(self)
653    }
654
655    /// Compute the distance between the origin and a point (`x`, `y`) on the
656    /// Euclidean plane. Equivalently, compute the length of the hypotenuse of a
657    /// right-angle triangle with other sides having length `x.abs()` and
658    /// `y.abs()`.
659    ///
660    /// # Unspecified precision
661    ///
662    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
663    /// can even differ within the same execution from one invocation to the next.
664    /// This function currently corresponds to the `hypot` from libc on Unix
665    /// and Windows. Note that this might change in the future.
666    ///
667    /// # Examples
668    ///
669    /// ```
670    /// let x = 2.0_f64;
671    /// let y = 3.0_f64;
672    ///
673    /// // sqrt(x^2 + y^2)
674    /// let abs_difference = (x.hypot(y) - (x.powi(2) + y.powi(2)).sqrt()).abs();
675    ///
676    /// assert!(abs_difference < 1e-10);
677    /// ```
678    #[rustc_allow_incoherent_impl]
679    #[must_use = "method returns a new number and does not mutate the original value"]
680    #[stable(feature = "rust1", since = "1.0.0")]
681    #[inline]
682    pub fn hypot(self, other: f64) -> f64 {
683        cmath::hypot(self, other)
684    }
685
686    /// Computes the sine of a number (in radians).
687    ///
688    /// # Unspecified precision
689    ///
690    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
691    /// can even differ within the same execution from one invocation to the next.
692    ///
693    /// # Examples
694    ///
695    /// ```
696    /// let x = std::f64::consts::FRAC_PI_2;
697    ///
698    /// let abs_difference = (x.sin() - 1.0).abs();
699    ///
700    /// assert!(abs_difference < 1e-10);
701    /// ```
702    #[rustc_allow_incoherent_impl]
703    #[must_use = "method returns a new number and does not mutate the original value"]
704    #[stable(feature = "rust1", since = "1.0.0")]
705    #[inline]
706    pub fn sin(self) -> f64 {
707        intrinsics::sin(self)
708    }
709
710    /// Computes the cosine of a number (in radians).
711    ///
712    /// # Unspecified precision
713    ///
714    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
715    /// can even differ within the same execution from one invocation to the next.
716    ///
717    /// # Examples
718    ///
719    /// ```
720    /// let x = 2.0 * std::f64::consts::PI;
721    ///
722    /// let abs_difference = (x.cos() - 1.0).abs();
723    ///
724    /// assert!(abs_difference < 1e-10);
725    /// ```
726    #[rustc_allow_incoherent_impl]
727    #[must_use = "method returns a new number and does not mutate the original value"]
728    #[stable(feature = "rust1", since = "1.0.0")]
729    #[inline]
730    pub fn cos(self) -> f64 {
731        intrinsics::cos(self)
732    }
733
734    /// Computes the tangent of a number (in radians).
735    ///
736    /// # Unspecified precision
737    ///
738    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
739    /// can even differ within the same execution from one invocation to the next.
740    /// This function currently corresponds to the `tan` from libc on Unix and
741    /// Windows. Note that this might change in the future.
742    ///
743    /// # Examples
744    ///
745    /// ```
746    /// let x = std::f64::consts::FRAC_PI_4;
747    /// let abs_difference = (x.tan() - 1.0).abs();
748    ///
749    /// assert!(abs_difference < 1e-14);
750    /// ```
751    #[rustc_allow_incoherent_impl]
752    #[must_use = "method returns a new number and does not mutate the original value"]
753    #[stable(feature = "rust1", since = "1.0.0")]
754    #[inline]
755    pub fn tan(self) -> f64 {
756        cmath::tan(self)
757    }
758
759    /// Computes the arcsine of a number. Return value is in radians in
760    /// the range [-pi/2, pi/2] or NaN if the number is outside the range
761    /// [-1, 1].
762    ///
763    /// # Unspecified precision
764    ///
765    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
766    /// can even differ within the same execution from one invocation to the next.
767    /// This function currently corresponds to the `asin` from libc on Unix and
768    /// Windows. Note that this might change in the future.
769    ///
770    /// # Examples
771    ///
772    /// ```
773    /// let f = std::f64::consts::FRAC_PI_4;
774    ///
775    /// // asin(sin(pi/2))
776    /// let abs_difference = (f.sin().asin() - f).abs();
777    ///
778    /// assert!(abs_difference < 1e-14);
779    /// ```
780    #[doc(alias = "arcsin")]
781    #[rustc_allow_incoherent_impl]
782    #[must_use = "method returns a new number and does not mutate the original value"]
783    #[stable(feature = "rust1", since = "1.0.0")]
784    #[inline]
785    pub fn asin(self) -> f64 {
786        cmath::asin(self)
787    }
788
789    /// Computes the arccosine of a number. Return value is in radians in
790    /// the range [0, pi] or NaN if the number is outside the range
791    /// [-1, 1].
792    ///
793    /// # Unspecified precision
794    ///
795    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
796    /// can even differ within the same execution from one invocation to the next.
797    /// This function currently corresponds to the `acos` from libc on Unix and
798    /// Windows. Note that this might change in the future.
799    ///
800    /// # Examples
801    ///
802    /// ```
803    /// let f = std::f64::consts::FRAC_PI_4;
804    ///
805    /// // acos(cos(pi/4))
806    /// let abs_difference = (f.cos().acos() - std::f64::consts::FRAC_PI_4).abs();
807    ///
808    /// assert!(abs_difference < 1e-10);
809    /// ```
810    #[doc(alias = "arccos")]
811    #[rustc_allow_incoherent_impl]
812    #[must_use = "method returns a new number and does not mutate the original value"]
813    #[stable(feature = "rust1", since = "1.0.0")]
814    #[inline]
815    pub fn acos(self) -> f64 {
816        cmath::acos(self)
817    }
818
819    /// Computes the arctangent of a number. Return value is in radians in the
820    /// range [-pi/2, pi/2];
821    ///
822    /// # Unspecified precision
823    ///
824    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
825    /// can even differ within the same execution from one invocation to the next.
826    /// This function currently corresponds to the `atan` from libc on Unix and
827    /// Windows. Note that this might change in the future.
828    ///
829    /// # Examples
830    ///
831    /// ```
832    /// let f = 1.0_f64;
833    ///
834    /// // atan(tan(1))
835    /// let abs_difference = (f.tan().atan() - 1.0).abs();
836    ///
837    /// assert!(abs_difference < 1e-10);
838    /// ```
839    #[doc(alias = "arctan")]
840    #[rustc_allow_incoherent_impl]
841    #[must_use = "method returns a new number and does not mutate the original value"]
842    #[stable(feature = "rust1", since = "1.0.0")]
843    #[inline]
844    pub fn atan(self) -> f64 {
845        cmath::atan(self)
846    }
847
848    /// Computes the four quadrant arctangent of `self` (`y`) and `other` (`x`) in radians.
849    ///
850    ///  | `x`     | `y`     | Piecewise Definition | Range         |
851    ///  |---------|---------|----------------------|---------------|
852    ///  | `>= +0` | `>= +0` | `arctan(y/x)`        | `[+0, +pi/2]` |
853    ///  | `>= +0` | `<= -0` | `arctan(y/x)`        | `[-pi/2, -0]` |
854    ///  | `<= -0` | `>= +0` | `arctan(y/x) + pi`   | `[+pi/2, +pi]`|
855    ///  | `<= -0` | `<= -0` | `arctan(y/x) - pi`   | `[-pi, -pi/2]`|
856    ///
857    /// # Unspecified precision
858    ///
859    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
860    /// can even differ within the same execution from one invocation to the next.
861    /// This function currently corresponds to the `atan2` from libc on Unix
862    /// and Windows. Note that this might change in the future.
863    ///
864    /// # Examples
865    ///
866    /// ```
867    /// // Positive angles measured counter-clockwise
868    /// // from positive x axis
869    /// // -pi/4 radians (45 deg clockwise)
870    /// let x1 = 3.0_f64;
871    /// let y1 = -3.0_f64;
872    ///
873    /// // 3pi/4 radians (135 deg counter-clockwise)
874    /// let x2 = -3.0_f64;
875    /// let y2 = 3.0_f64;
876    ///
877    /// let abs_difference_1 = (y1.atan2(x1) - (-std::f64::consts::FRAC_PI_4)).abs();
878    /// let abs_difference_2 = (y2.atan2(x2) - (3.0 * std::f64::consts::FRAC_PI_4)).abs();
879    ///
880    /// assert!(abs_difference_1 < 1e-10);
881    /// assert!(abs_difference_2 < 1e-10);
882    /// ```
883    #[rustc_allow_incoherent_impl]
884    #[must_use = "method returns a new number and does not mutate the original value"]
885    #[stable(feature = "rust1", since = "1.0.0")]
886    #[inline]
887    pub fn atan2(self, other: f64) -> f64 {
888        cmath::atan2(self, other)
889    }
890
891    /// Simultaneously computes the sine and cosine of the number, `x`. Returns
892    /// `(sin(x), cos(x))`.
893    ///
894    /// # Unspecified precision
895    ///
896    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
897    /// can even differ within the same execution from one invocation to the next.
898    /// This function currently corresponds to the `(f64::sin(x),
899    /// f64::cos(x))`. Note that this might change in the future.
900    ///
901    /// # Examples
902    ///
903    /// ```
904    /// let x = std::f64::consts::FRAC_PI_4;
905    /// let f = x.sin_cos();
906    ///
907    /// let abs_difference_0 = (f.0 - x.sin()).abs();
908    /// let abs_difference_1 = (f.1 - x.cos()).abs();
909    ///
910    /// assert!(abs_difference_0 < 1e-10);
911    /// assert!(abs_difference_1 < 1e-10);
912    /// ```
913    #[doc(alias = "sincos")]
914    #[rustc_allow_incoherent_impl]
915    #[stable(feature = "rust1", since = "1.0.0")]
916    #[inline]
917    #[must_use = "this returns the result of the operation, without modifying the original"]
918    pub fn sin_cos(self) -> (f64, f64) {
919        (self.sin(), self.cos())
920    }
921
922    /// Returns `e^(self) - 1` in a way that is accurate even if the
923    /// number is close to zero.
924    ///
925    /// # Unspecified precision
926    ///
927    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
928    /// can even differ within the same execution from one invocation to the next.
929    /// This function currently corresponds to the `expm1` from libc on Unix
930    /// and Windows. Note that this might change in the future.
931    ///
932    /// # Examples
933    ///
934    /// ```
935    /// let x = 1e-16_f64;
936    ///
937    /// // for very small x, e^x is approximately 1 + x + x^2 / 2
938    /// let approx = x + x * x / 2.0;
939    /// let abs_difference = (x.exp_m1() - approx).abs();
940    ///
941    /// assert!(abs_difference < 1e-20);
942    /// ```
943    #[rustc_allow_incoherent_impl]
944    #[must_use = "method returns a new number and does not mutate the original value"]
945    #[stable(feature = "rust1", since = "1.0.0")]
946    #[inline]
947    pub fn exp_m1(self) -> f64 {
948        cmath::expm1(self)
949    }
950
951    /// Returns `ln(1+n)` (natural logarithm) more accurately than if
952    /// the operations were performed separately.
953    ///
954    /// This returns NaN when `n < -1.0`, and negative infinity when `n == -1.0`.
955    ///
956    /// # Unspecified precision
957    ///
958    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
959    /// can even differ within the same execution from one invocation to the next.
960    /// This function currently corresponds to the `log1p` from libc on Unix
961    /// and Windows. Note that this might change in the future.
962    ///
963    /// # Examples
964    ///
965    /// ```
966    /// let x = 1e-16_f64;
967    ///
968    /// // for very small x, ln(1 + x) is approximately x - x^2 / 2
969    /// let approx = x - x * x / 2.0;
970    /// let abs_difference = (x.ln_1p() - approx).abs();
971    ///
972    /// assert!(abs_difference < 1e-20);
973    /// ```
974    ///
975    /// Out-of-range values:
976    /// ```
977    /// assert_eq!((-1.0_f64).ln_1p(), f64::NEG_INFINITY);
978    /// assert!((-2.0_f64).ln_1p().is_nan());
979    /// ```
980    #[doc(alias = "log1p")]
981    #[rustc_allow_incoherent_impl]
982    #[must_use = "method returns a new number and does not mutate the original value"]
983    #[stable(feature = "rust1", since = "1.0.0")]
984    #[inline]
985    pub fn ln_1p(self) -> f64 {
986        cmath::log1p(self)
987    }
988
989    /// Hyperbolic sine function.
990    ///
991    /// # Unspecified precision
992    ///
993    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
994    /// can even differ within the same execution from one invocation to the next.
995    /// This function currently corresponds to the `sinh` from libc on Unix
996    /// and Windows. Note that this might change in the future.
997    ///
998    /// # Examples
999    ///
1000    /// ```
1001    /// let e = std::f64::consts::E;
1002    /// let x = 1.0_f64;
1003    ///
1004    /// let f = x.sinh();
1005    /// // Solving sinh() at 1 gives `(e^2-1)/(2e)`
1006    /// let g = ((e * e) - 1.0) / (2.0 * e);
1007    /// let abs_difference = (f - g).abs();
1008    ///
1009    /// assert!(abs_difference < 1e-10);
1010    /// ```
1011    #[rustc_allow_incoherent_impl]
1012    #[must_use = "method returns a new number and does not mutate the original value"]
1013    #[stable(feature = "rust1", since = "1.0.0")]
1014    #[inline]
1015    pub fn sinh(self) -> f64 {
1016        cmath::sinh(self)
1017    }
1018
1019    /// Hyperbolic cosine function.
1020    ///
1021    /// # Unspecified precision
1022    ///
1023    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
1024    /// can even differ within the same execution from one invocation to the next.
1025    /// This function currently corresponds to the `cosh` from libc on Unix
1026    /// and Windows. Note that this might change in the future.
1027    ///
1028    /// # Examples
1029    ///
1030    /// ```
1031    /// let e = std::f64::consts::E;
1032    /// let x = 1.0_f64;
1033    /// let f = x.cosh();
1034    /// // Solving cosh() at 1 gives this result
1035    /// let g = ((e * e) + 1.0) / (2.0 * e);
1036    /// let abs_difference = (f - g).abs();
1037    ///
1038    /// // Same result
1039    /// assert!(abs_difference < 1.0e-10);
1040    /// ```
1041    #[rustc_allow_incoherent_impl]
1042    #[must_use = "method returns a new number and does not mutate the original value"]
1043    #[stable(feature = "rust1", since = "1.0.0")]
1044    #[inline]
1045    pub fn cosh(self) -> f64 {
1046        cmath::cosh(self)
1047    }
1048
1049    /// Hyperbolic tangent function.
1050    ///
1051    /// # Unspecified precision
1052    ///
1053    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
1054    /// can even differ within the same execution from one invocation to the next.
1055    /// This function currently corresponds to the `tanh` from libc on Unix
1056    /// and Windows. Note that this might change in the future.
1057    ///
1058    /// # Examples
1059    ///
1060    /// ```
1061    /// let e = std::f64::consts::E;
1062    /// let x = 1.0_f64;
1063    ///
1064    /// let f = x.tanh();
1065    /// // Solving tanh() at 1 gives `(1 - e^(-2))/(1 + e^(-2))`
1066    /// let g = (1.0 - e.powi(-2)) / (1.0 + e.powi(-2));
1067    /// let abs_difference = (f - g).abs();
1068    ///
1069    /// assert!(abs_difference < 1.0e-10);
1070    /// ```
1071    #[rustc_allow_incoherent_impl]
1072    #[must_use = "method returns a new number and does not mutate the original value"]
1073    #[stable(feature = "rust1", since = "1.0.0")]
1074    #[inline]
1075    pub fn tanh(self) -> f64 {
1076        cmath::tanh(self)
1077    }
1078
1079    /// Inverse hyperbolic sine function.
1080    ///
1081    /// # Unspecified precision
1082    ///
1083    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
1084    /// can even differ within the same execution from one invocation to the next.
1085    ///
1086    /// # Examples
1087    ///
1088    /// ```
1089    /// let x = 1.0_f64;
1090    /// let f = x.sinh().asinh();
1091    ///
1092    /// let abs_difference = (f - x).abs();
1093    ///
1094    /// assert!(abs_difference < 1.0e-10);
1095    /// ```
1096    #[doc(alias = "arcsinh")]
1097    #[rustc_allow_incoherent_impl]
1098    #[must_use = "method returns a new number and does not mutate the original value"]
1099    #[stable(feature = "rust1", since = "1.0.0")]
1100    #[inline]
1101    pub fn asinh(self) -> f64 {
1102        cmath::asinh(self)
1103    }
1104
1105    /// Inverse hyperbolic cosine function.
1106    ///
1107    /// # Unspecified precision
1108    ///
1109    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
1110    /// can even differ within the same execution from one invocation to the next.
1111    ///
1112    /// # Examples
1113    ///
1114    /// ```
1115    /// let x = 1.0_f64;
1116    /// let f = x.cosh().acosh();
1117    ///
1118    /// let abs_difference = (f - x).abs();
1119    ///
1120    /// assert!(abs_difference < 1.0e-10);
1121    /// ```
1122    #[doc(alias = "arccosh")]
1123    #[rustc_allow_incoherent_impl]
1124    #[must_use = "method returns a new number and does not mutate the original value"]
1125    #[stable(feature = "rust1", since = "1.0.0")]
1126    #[inline]
1127    pub fn acosh(self) -> f64 {
1128        cmath::acosh(self)
1129    }
1130
1131    /// Inverse hyperbolic tangent function.
1132    ///
1133    /// # Unspecified precision
1134    ///
1135    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
1136    /// can even differ within the same execution from one invocation to the next.
1137    ///
1138    /// # Examples
1139    ///
1140    /// ```
1141    /// let x = std::f64::consts::FRAC_PI_6;
1142    /// let f = x.tanh().atanh();
1143    ///
1144    /// let abs_difference = (f - x).abs();
1145    ///
1146    /// assert!(abs_difference < 1.0e-10);
1147    /// ```
1148    #[doc(alias = "arctanh")]
1149    #[rustc_allow_incoherent_impl]
1150    #[must_use = "method returns a new number and does not mutate the original value"]
1151    #[stable(feature = "rust1", since = "1.0.0")]
1152    #[inline]
1153    pub fn atanh(self) -> f64 {
1154        0.5 * ((2.0 * self) / (1.0 - self)).ln_1p()
1155    }
1156
1157    /// Gamma function.
1158    ///
1159    /// # Unspecified precision
1160    ///
1161    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
1162    /// can even differ within the same execution from one invocation to the next.
1163    /// This function currently corresponds to the `tgamma` from libc on Unix
1164    /// and Windows. Note that this might change in the future.
1165    ///
1166    /// # Examples
1167    ///
1168    /// ```
1169    /// #![feature(float_gamma)]
1170    /// let x = 5.0f64;
1171    ///
1172    /// let abs_difference = (x.gamma() - 24.0).abs();
1173    ///
1174    /// assert!(abs_difference <= 1e-10);
1175    /// ```
1176    #[rustc_allow_incoherent_impl]
1177    #[must_use = "method returns a new number and does not mutate the original value"]
1178    #[unstable(feature = "float_gamma", issue = "99842")]
1179    #[inline]
1180    pub fn gamma(self) -> f64 {
1181        cmath::tgamma(self)
1182    }
1183
1184    /// Natural logarithm of the absolute value of the gamma function
1185    ///
1186    /// The integer part of the tuple indicates the sign of the gamma function.
1187    ///
1188    /// # Unspecified precision
1189    ///
1190    /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
1191    /// can even differ within the same execution from one invocation to the next.
1192    /// This function currently corresponds to the `lgamma_r` from libc on Unix
1193    /// and Windows. Note that this might change in the future.
1194    ///
1195    /// # Examples
1196    ///
1197    /// ```
1198    /// #![feature(float_gamma)]
1199    /// let x = 2.0f64;
1200    ///
1201    /// let abs_difference = (x.ln_gamma().0 - 0.0).abs();
1202    ///
1203    /// assert!(abs_difference <= f64::EPSILON);
1204    /// ```
1205    #[rustc_allow_incoherent_impl]
1206    #[must_use = "method returns a new number and does not mutate the original value"]
1207    #[unstable(feature = "float_gamma", issue = "99842")]
1208    #[inline]
1209    pub fn ln_gamma(self) -> (f64, i32) {
1210        let mut signgamp: i32 = 0;
1211        let x = cmath::lgamma_r(self, &mut signgamp);
1212        (x, signgamp)
1213    }
1214
1215    /// Error function.
1216    ///
1217    /// # Unspecified precision
1218    ///
1219    /// The precision of this function is non-deterministic. This means it varies by platform,
1220    /// Rust version, and can even differ within the same execution from one invocation to the next.
1221    ///
1222    /// This function currently corresponds to the `erf` from libc on Unix
1223    /// and Windows. Note that this might change in the future.
1224    ///
1225    /// # Examples
1226    ///
1227    /// ```
1228    /// #![feature(float_erf)]
1229    /// /// The error function relates what percent of a normal distribution lies
1230    /// /// within `x` standard deviations (scaled by `1/sqrt(2)`).
1231    /// fn within_standard_deviations(x: f64) -> f64 {
1232    ///     (x * std::f64::consts::FRAC_1_SQRT_2).erf() * 100.0
1233    /// }
1234    ///
1235    /// // 68% of a normal distribution is within one standard deviation
1236    /// assert!((within_standard_deviations(1.0) - 68.269).abs() < 0.01);
1237    /// // 95% of a normal distribution is within two standard deviations
1238    /// assert!((within_standard_deviations(2.0) - 95.450).abs() < 0.01);
1239    /// // 99.7% of a normal distribution is within three standard deviations
1240    /// assert!((within_standard_deviations(3.0) - 99.730).abs() < 0.01);
1241    /// ```
1242    #[rustc_allow_incoherent_impl]
1243    #[must_use = "method returns a new number and does not mutate the original value"]
1244    #[unstable(feature = "float_erf", issue = "136321")]
1245    #[inline]
1246    pub fn erf(self) -> f64 {
1247        cmath::erf(self)
1248    }
1249
1250    /// Complementary error function.
1251    ///
1252    /// # Unspecified precision
1253    ///
1254    /// The precision of this function is non-deterministic. This means it varies by platform,
1255    /// Rust version, and can even differ within the same execution from one invocation to the next.
1256    ///
1257    /// This function currently corresponds to the `erfc` from libc on Unix
1258    /// and Windows. Note that this might change in the future.
1259    ///
1260    /// # Examples
1261    ///
1262    /// ```
1263    /// #![feature(float_erf)]
1264    /// let x: f64 = 0.123;
1265    ///
1266    /// let one = x.erf() + x.erfc();
1267    /// let abs_difference = (one - 1.0).abs();
1268    ///
1269    /// assert!(abs_difference <= 1e-10);
1270    /// ```
1271    #[rustc_allow_incoherent_impl]
1272    #[must_use = "method returns a new number and does not mutate the original value"]
1273    #[unstable(feature = "float_erf", issue = "136321")]
1274    #[inline]
1275    pub fn erfc(self) -> f64 {
1276        cmath::erfc(self)
1277    }
1278}