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