summaryrefslogtreecommitdiffstats
path: root/library/std/src/f32.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/f32.rs')
-rw-r--r--library/std/src/f32.rs57
1 files changed, 53 insertions, 4 deletions
diff --git a/library/std/src/f32.rs b/library/std/src/f32.rs
index bed90418b..a659b552f 100644
--- a/library/std/src/f32.rs
+++ b/library/std/src/f32.rs
@@ -61,6 +61,7 @@ impl f32 {
/// assert_eq!(f.ceil(), 4.0);
/// assert_eq!(g.ceil(), 4.0);
/// ```
+ #[doc(alias = "ceiling")]
#[rustc_allow_incoherent_impl]
#[must_use = "method returns a new number and does not mutate the original value"]
#[stable(feature = "rust1", since = "1.0.0")]
@@ -135,6 +136,7 @@ impl f32 {
/// assert_eq!(g.trunc(), 3.0);
/// assert_eq!(h.trunc(), -3.0);
/// ```
+ #[doc(alias = "truncate")]
#[rustc_allow_incoherent_impl]
#[must_use = "method returns a new number and does not mutate the original value"]
#[stable(feature = "rust1", since = "1.0.0")]
@@ -321,6 +323,7 @@ impl f32 {
/// // limitation due to round-off error
/// assert!((-f32::EPSILON).rem_euclid(3.0) != 0.0);
/// ```
+ #[doc(alias = "modulo", alias = "mod")]
#[rustc_allow_incoherent_impl]
#[must_use = "method returns a new number and does not mutate the original value"]
#[inline]
@@ -500,10 +503,7 @@ impl f32 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn log2(self) -> f32 {
- #[cfg(target_os = "android")]
- return crate::sys::android::log2f32(self);
- #[cfg(not(target_os = "android"))]
- return unsafe { intrinsics::log2f32(self) };
+ crate::sys::log2f32(self)
}
/// Returns the base 10 logarithm of the number.
@@ -675,6 +675,7 @@ impl f32 {
///
/// assert!(abs_difference <= f32::EPSILON);
/// ```
+ #[doc(alias = "arcsin")]
#[rustc_allow_incoherent_impl]
#[must_use = "method returns a new number and does not mutate the original value"]
#[stable(feature = "rust1", since = "1.0.0")]
@@ -697,6 +698,7 @@ impl f32 {
///
/// assert!(abs_difference <= f32::EPSILON);
/// ```
+ #[doc(alias = "arccos")]
#[rustc_allow_incoherent_impl]
#[must_use = "method returns a new number and does not mutate the original value"]
#[stable(feature = "rust1", since = "1.0.0")]
@@ -718,6 +720,7 @@ impl f32 {
///
/// assert!(abs_difference <= f32::EPSILON);
/// ```
+ #[doc(alias = "arctan")]
#[rustc_allow_incoherent_impl]
#[must_use = "method returns a new number and does not mutate the original value"]
#[stable(feature = "rust1", since = "1.0.0")]
@@ -775,6 +778,7 @@ impl f32 {
/// assert!(abs_difference_0 <= f32::EPSILON);
/// assert!(abs_difference_1 <= f32::EPSILON);
/// ```
+ #[doc(alias = "sincos")]
#[rustc_allow_incoherent_impl]
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
@@ -907,6 +911,7 @@ impl f32 {
///
/// assert!(abs_difference <= f32::EPSILON);
/// ```
+ #[doc(alias = "arcsinh")]
#[rustc_allow_incoherent_impl]
#[must_use = "method returns a new number and does not mutate the original value"]
#[stable(feature = "rust1", since = "1.0.0")]
@@ -929,6 +934,7 @@ impl f32 {
///
/// assert!(abs_difference <= f32::EPSILON);
/// ```
+ #[doc(alias = "arccosh")]
#[rustc_allow_incoherent_impl]
#[must_use = "method returns a new number and does not mutate the original value"]
#[stable(feature = "rust1", since = "1.0.0")]
@@ -953,6 +959,7 @@ impl f32 {
///
/// assert!(abs_difference <= 1e-5);
/// ```
+ #[doc(alias = "arctanh")]
#[rustc_allow_incoherent_impl]
#[must_use = "method returns a new number and does not mutate the original value"]
#[stable(feature = "rust1", since = "1.0.0")]
@@ -960,4 +967,46 @@ impl f32 {
pub fn atanh(self) -> f32 {
0.5 * ((2.0 * self) / (1.0 - self)).ln_1p()
}
+
+ /// Gamma function.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// #![feature(float_gamma)]
+ /// let x = 5.0f32;
+ ///
+ /// let abs_difference = (x.gamma() - 24.0).abs();
+ ///
+ /// assert!(abs_difference <= f32::EPSILON);
+ /// ```
+ #[rustc_allow_incoherent_impl]
+ #[must_use = "method returns a new number and does not mutate the original value"]
+ #[unstable(feature = "float_gamma", issue = "99842")]
+ #[inline]
+ pub fn gamma(self) -> f32 {
+ unsafe { cmath::tgammaf(self) }
+ }
+
+ /// Returns the natural logarithm of the gamma function.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// #![feature(float_gamma)]
+ /// let x = 2.0f32;
+ ///
+ /// let abs_difference = (x.ln_gamma().0 - 0.0).abs();
+ ///
+ /// assert!(abs_difference <= f32::EPSILON);
+ /// ```
+ #[rustc_allow_incoherent_impl]
+ #[must_use = "method returns a new number and does not mutate the original value"]
+ #[unstable(feature = "float_gamma", issue = "99842")]
+ #[inline]
+ pub fn ln_gamma(self) -> (f32, i32) {
+ let mut signgamp: i32 = 0;
+ let x = unsafe { cmath::lgammaf_r(self, &mut signgamp) };
+ (x, signgamp)
+ }
}