@@ -1226,6 +1226,7 @@ impl f128 {
1226
1226
#[ inline]
1227
1227
#[ rustc_allow_incoherent_impl]
1228
1228
#[ unstable( feature = "f128" , issue = "116909" ) ]
1229
+ // #[unstable(feature = "float_gamma", issue = "99842")]
1229
1230
#[ must_use = "method returns a new number and does not mutate the original value" ]
1230
1231
pub fn gamma ( self ) -> f128 {
1231
1232
unsafe { cmath:: tgammaf128 ( self ) }
@@ -1260,10 +1261,83 @@ impl f128 {
1260
1261
#[ inline]
1261
1262
#[ rustc_allow_incoherent_impl]
1262
1263
#[ unstable( feature = "f128" , issue = "116909" ) ]
1264
+ // #[unstable(feature = "float_gamma", issue = "99842")]
1263
1265
#[ must_use = "method returns a new number and does not mutate the original value" ]
1264
1266
pub fn ln_gamma ( self ) -> ( f128 , i32 ) {
1265
1267
let mut signgamp: i32 = 0 ;
1266
1268
let x = unsafe { cmath:: lgammaf128_r ( self , & mut signgamp) } ;
1267
1269
( x, signgamp)
1268
1270
}
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
+ }
1269
1343
}
0 commit comments