Commit 3d6c6fa 1 parent 8231e85 commit 3d6c6fa Copy full SHA for 3d6c6fa
File tree 4 files changed +44
-6
lines changed
4 files changed +44
-6
lines changed Original file line number Diff line number Diff line change @@ -324,6 +324,20 @@ impl f128 {
324
324
///
325
325
/// The precision of this function is non-deterministic. This means it varies by platform,
326
326
/// Rust version, and can even differ within the same execution from one invocation to the next.
327
+ ///
328
+ /// # Examples
329
+ ///
330
+ /// ```
331
+ /// #![feature(f128)]
332
+ /// # #[cfg(reliable_f128_math)] {
333
+ ///
334
+ /// let x = 2.0_f128;
335
+ /// let abs_difference = (x.powi(2) - (x * x)).abs();
336
+ /// assert!(abs_difference <= f128::EPSILON);
337
+ ///
338
+ /// assert_eq!(f128::powi(f128::NAN, 0), 1.0);
339
+ /// # }
340
+ /// ```
327
341
#[ inline]
328
342
#[ rustc_allow_incoherent_impl]
329
343
#[ unstable( feature = "f128" , issue = "116909" ) ]
@@ -347,8 +361,10 @@ impl f128 {
347
361
///
348
362
/// let x = 2.0_f128;
349
363
/// let abs_difference = (x.powf(2.0) - (x * x)).abs();
350
- ///
351
364
/// assert!(abs_difference <= f128::EPSILON);
365
+ ///
366
+ /// assert_eq!(f128::powf(1.0, f128::NAN), 1.0);
367
+ /// assert_eq!(f128::powf(f128::NAN, 0.0), 1.0);
352
368
/// # }
353
369
/// ```
354
370
#[ inline]
Original file line number Diff line number Diff line change @@ -324,6 +324,20 @@ impl f16 {
324
324
///
325
325
/// The precision of this function is non-deterministic. This means it varies by platform,
326
326
/// Rust version, and can even differ within the same execution from one invocation to the next.
327
+ ///
328
+ /// # Examples
329
+ ///
330
+ /// ```
331
+ /// #![feature(f16)]
332
+ /// # #[cfg(reliable_f16_math)] {
333
+ ///
334
+ /// let x = 2.0_f16;
335
+ /// let abs_difference = (x.powi(2) - (x * x)).abs();
336
+ /// assert!(abs_difference <= f16::EPSILON);
337
+ ///
338
+ /// assert_eq!(f16::powi(f16::NAN, 0), 1.0);
339
+ /// # }
340
+ /// ```
327
341
#[ inline]
328
342
#[ rustc_allow_incoherent_impl]
329
343
#[ unstable( feature = "f16" , issue = "116909" ) ]
@@ -347,8 +361,10 @@ impl f16 {
347
361
///
348
362
/// let x = 2.0_f16;
349
363
/// let abs_difference = (x.powf(2.0) - (x * x)).abs();
350
- ///
351
364
/// assert!(abs_difference <= f16::EPSILON);
365
+ ///
366
+ /// assert_eq!(f16::powf(1.0, f16::NAN), 1.0);
367
+ /// assert_eq!(f16::powf(f16::NAN, 0.0), 1.0);
352
368
/// # }
353
369
/// ```
354
370
#[ inline]
Original file line number Diff line number Diff line change @@ -306,8 +306,9 @@ impl f32 {
306
306
/// ```
307
307
/// let x = 2.0_f32;
308
308
/// let abs_difference = (x.powi(2) - (x * x)).abs();
309
- ///
310
309
/// assert!(abs_difference <= f32::EPSILON);
310
+ ///
311
+ /// assert_eq!(f32::powi(f32::NAN, 0), 1.0);
311
312
/// ```
312
313
#[ rustc_allow_incoherent_impl]
313
314
#[ must_use = "method returns a new number and does not mutate the original value" ]
@@ -329,8 +330,10 @@ impl f32 {
329
330
/// ```
330
331
/// let x = 2.0_f32;
331
332
/// let abs_difference = (x.powf(2.0) - (x * x)).abs();
332
- ///
333
333
/// assert!(abs_difference <= f32::EPSILON);
334
+ ///
335
+ /// assert_eq!(f32::powf(1.0, f32::NAN), 1.0);
336
+ /// assert_eq!(f32::powf(f32::NAN, 0.0), 1.0);
334
337
/// ```
335
338
#[ rustc_allow_incoherent_impl]
336
339
#[ must_use = "method returns a new number and does not mutate the original value" ]
Original file line number Diff line number Diff line change @@ -306,8 +306,9 @@ impl f64 {
306
306
/// ```
307
307
/// let x = 2.0_f64;
308
308
/// let abs_difference = (x.powi(2) - (x * x)).abs();
309
+ /// assert!(abs_difference <= f64::EPSILON);
309
310
///
310
- /// assert!(abs_difference < 1e-10 );
311
+ /// assert_eq!(f64::powi(f64::NAN, 0), 1.0 );
311
312
/// ```
312
313
#[ rustc_allow_incoherent_impl]
313
314
#[ must_use = "method returns a new number and does not mutate the original value" ]
@@ -329,8 +330,10 @@ impl f64 {
329
330
/// ```
330
331
/// let x = 2.0_f64;
331
332
/// let abs_difference = (x.powf(2.0) - (x * x)).abs();
333
+ /// assert!(abs_difference <= f64::EPSILON);
332
334
///
333
- /// assert!(abs_difference < 1e-10);
335
+ /// assert_eq!(f64::powf(1.0, f64::NAN), 1.0);
336
+ /// assert_eq!(f64::powf(f64::NAN, 0.0), 1.0);
334
337
/// ```
335
338
#[ rustc_allow_incoherent_impl]
336
339
#[ must_use = "method returns a new number and does not mutate the original value" ]
You can’t perform that action at this time.
0 commit comments