Skip to main content

std/num/
f32.rs

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