@@ -1226,6 +1226,7 @@ impl f128 {
12261226 #[ inline]
12271227 #[ rustc_allow_incoherent_impl]
12281228 #[ unstable( feature = "f128" , issue = "116909" ) ]
1229+ // #[unstable(feature = "float_gamma", issue = "99842")]
12291230 #[ must_use = "method returns a new number and does not mutate the original value" ]
12301231 pub fn gamma ( self ) -> f128 {
12311232 unsafe { cmath:: tgammaf128 ( self ) }
@@ -1260,10 +1261,83 @@ impl f128 {
12601261 #[ inline]
12611262 #[ rustc_allow_incoherent_impl]
12621263 #[ unstable( feature = "f128" , issue = "116909" ) ]
1264+ // #[unstable(feature = "float_gamma", issue = "99842")]
12631265 #[ must_use = "method returns a new number and does not mutate the original value" ]
12641266 pub fn ln_gamma ( self ) -> ( f128 , i32 ) {
12651267 let mut signgamp: i32 = 0 ;
12661268 let x = unsafe { cmath:: lgammaf128_r ( self , & mut signgamp) } ;
12671269 ( x, signgamp)
12681270 }
1271+
1272+ /// Error function.
1273+ ///
1274+ /// # Unspecified precision
1275+ ///
1276+ /// The precision of this function is non-deterministic. This means it varies by platform,
1277+ /// Rust version, and can even differ within the same execution from one invocation to the next.
1278+ ///
1279+ /// This function currently corresponds to the `erff128` from libc on Unix
1280+ /// and Windows. Note that this might change in the future.
1281+ ///
1282+ /// # Examples
1283+ ///
1284+ /// ```
1285+ /// #![feature(f128)]
1286+ /// #![feature(float_erf)]
1287+ /// # #[cfg(reliable_f128_math)] {
1288+ /// /// The error function relates what percent of a normal distribution lies
1289+ /// /// within `x` standard deviations (scaled by `1/sqrt(2)`).
1290+ /// fn within_standard_deviations(x: f128) -> f128 {
1291+ /// (x * std::f128::consts::FRAC_1_SQRT_2).erf() * 100.0
1292+ /// }
1293+ ///
1294+ /// // 68% of a normal distribution is within one standard deviation
1295+ /// assert!((within_standard_deviations(1.0) - 68.269).abs() < 0.01);
1296+ /// // 95% of a normal distribution is within two standard deviations
1297+ /// assert!((within_standard_deviations(2.0) - 95.450).abs() < 0.01);
1298+ /// // 99.7% of a normal distribution is within three standard deviations
1299+ /// assert!((within_standard_deviations(3.0) - 99.730).abs() < 0.01);
1300+ /// # }
1301+ /// ```
1302+ #[ rustc_allow_incoherent_impl]
1303+ #[ must_use = "method returns a new number and does not mutate the original value" ]
1304+ #[ unstable( feature = "f128" , issue = "116909" ) ]
1305+ // #[unstable(feature = "float_erf", issue = "136321")]
1306+ #[ inline]
1307+ pub fn erf ( self ) -> f128 {
1308+ unsafe { cmath:: erff128 ( self ) }
1309+ }
1310+
1311+ /// Complementary error function.
1312+ ///
1313+ /// # Unspecified precision
1314+ ///
1315+ /// The precision of this function is non-deterministic. This means it varies by platform,
1316+ /// Rust version, and can even differ within the same execution from one invocation to the next.
1317+ ///
1318+ /// This function currently corresponds to the `erfcf128` from libc on Unix
1319+ /// and Windows. Note that this might change in the future.
1320+ ///
1321+ /// # Examples
1322+ ///
1323+ /// ```
1324+ /// #![feature(f128)]
1325+ /// #![feature(float_erf)]
1326+ /// # #[cfg(reliable_f128_math)] {
1327+ /// let x: f128 = 0.123;
1328+ ///
1329+ /// let one = x.erf() + x.erfc();
1330+ /// let abs_difference = (one - 1.0).abs();
1331+ ///
1332+ /// assert!(abs_difference <= f128::EPSILON);
1333+ /// # }
1334+ /// ```
1335+ #[ rustc_allow_incoherent_impl]
1336+ #[ must_use = "method returns a new number and does not mutate the original value" ]
1337+ #[ unstable( feature = "f128" , issue = "116909" ) ]
1338+ // #[unstable(feature = "float_erf", issue = "136321")]
1339+ #[ inline]
1340+ pub fn erfc ( self ) -> f128 {
1341+ unsafe { cmath:: erfcf128 ( self ) }
1342+ }
12691343}
0 commit comments